UNPKG

wgutils

Version:

Tools for managing working groups

40 lines 1.28 kB
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.run = exports.options = void 0; const promises_1 = require("node:fs/promises"); const config_js_1 = require("../config.js"); function options(yargs) { return yargs.example("$0", "Initialize wgutils"); } exports.options = options; async function run(args) { try { await (0, config_js_1.loadConfig)(); throw new Error(`Config already exists; refusing to overwrite`); } catch (e) { if (e.code === "ERR_MODULE_NOT_FOUND") { const path = (0, config_js_1.getConfigPath)(); try { await (0, promises_1.stat)(path); throw new Error(`Config file already exists`); } catch (e) { if (e.code === "ENOENT") { // Fine } else { console.dir(e); process.exit(1); } } await (0, promises_1.writeFile)(path, config_js_1.template); console.log(`Example configuration written to '${path}'; please adjust as necessary.`); } else { throw e; } } } exports.run = run; //# sourceMappingURL=cli.js.map