UNPKG

@launchql/cli

Version:
31 lines (30 loc) 1.02 kB
import path from 'path'; import { LaunchQLPackage } from '@launchql/core'; export default async (argv, _prompter) => { const cwd = argv.cwd || process.cwd(); const to = argv.to || (argv._ && argv._[0]); if (!to) { console.error('Missing new name. Use --to <name> or provide as positional argument.'); process.exit(1); } const dryRun = !!argv['dry-run'] || !!argv.dryRun; const syncPkg = !!argv['sync-pkg-name'] || !!argv.syncPkgName; const proj = new LaunchQLPackage(path.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}`); } };