@launchql/cli
Version:
LaunchQL CLI
36 lines (35 loc) • 1.32 kB
JavaScript
var __importDefault = (this && this.__importDefault) || function (mod) {
return (mod && mod.__esModule) ? mod : { "default": mod };
};
Object.defineProperty(exports, "__esModule", { value: true });
const path_1 = __importDefault(require("path"));
const core_1 = require("@launchql/core");
const cli_error_1 = require("../utils/cli-error");
exports.default = async (argv, _prompter) => {
const cwd = argv.cwd || process.cwd();
const to = argv.to || (argv._ && argv._[0]);
if (!to) {
await (0, cli_error_1.cliExitWithError)('Missing new name. Use --to <name> or provide as positional argument.');
}
const dryRun = !!argv['dry-run'] || !!argv.dryRun;
const syncPkg = !!argv['sync-pkg-name'] || !!argv.syncPkgName;
const proj = new core_1.LaunchQLPackage(path_1.default.resolve(cwd));
const res = proj.renameModule(to, { dryRun, syncPackageJsonName: syncPkg });
if (dryRun) {
console.log('Dry run');
}
if (res.changed.length > 0) {
console.log('Changed:');
for (const f of res.changed)
console.log(`- ${f}`);
}
else {
console.log('No changes');
}
if (res.warnings.length > 0) {
console.log('Warnings:');
for (const w of res.warnings)
console.log(`- ${w}`);
}
};
;