UNPKG

pmcf

Version:

Poor mans configuration management

46 lines (40 loc) 939 B
import { parseArgs } from "node:util"; import { resolve } from "node:path"; import { argv, cwd, env } from "node:process"; import { Root } from "./module.mjs"; export async function prepare(options = {}) { const { values, positionals } = parseArgs({ args: argv.slice(2), options: { ...options, verbose: { type: "boolean", short: "v", default: false }, dry: { type: "boolean", default: false }, publish: { type: "string" }, root: { type: "string", short: "r", default: env.PMCF_ROOT || cwd() }, output: { type: "string", short: "o" } }, allowPositionals: true }); if (values.output) { values.output = resolve(cwd(), values.output); } const root = new Root(values.root); await root.loadAll(); return { root, options: values, args: positionals }; }