mono/packages/search/_cli.js
2025-03-11 11:28:14 +01:00

41 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 = Object.assign(Object.assign({}, ret), { variables: {} });
return ret;
};
exports.sanitize = sanitize;
//# sourceMappingURL=_cli.js.map