44 lines
1.2 KiB
JavaScript
44 lines
1.2 KiB
JavaScript
"use strict";
|
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
exports.sanitize = exports.defaults = void 0;
|
|
const exists_1 = require("@plastichub/fs/exists");
|
|
const _1 = require("./");
|
|
const path = require("path");
|
|
// tweaks and handlers
|
|
const defaults = () => {
|
|
// default command
|
|
const DefaultCommand = 'info';
|
|
if (process.argv.length === 2) {
|
|
process.argv.push(DefaultCommand);
|
|
}
|
|
// currently no default handler, display only :
|
|
process.on('unhandledRejection', (reason) => {
|
|
console.error('Unhandled rejection, reason: ', reason);
|
|
});
|
|
};
|
|
exports.defaults = defaults;
|
|
const sanitize = (argv) => {
|
|
let ret = {
|
|
all: argv.all,
|
|
src: argv.src,
|
|
types: argv.types,
|
|
dst: argv.dst,
|
|
depth: argv.dept
|
|
};
|
|
if (argv.cwd) {
|
|
ret.cwd = path.resolve(argv.cwd);
|
|
if (!(0, exists_1.sync)((ret.cwd))) {
|
|
_1.logger.error(`Invalid working directory ${argv.cwd}`);
|
|
}
|
|
}
|
|
else {
|
|
ret.cwd = process.cwd();
|
|
}
|
|
ret = {
|
|
...ret,
|
|
...{ variables: {} }
|
|
};
|
|
return ret;
|
|
};
|
|
exports.sanitize = sanitize;
|
|
//# sourceMappingURL=_cli.js.map
|