codemods: default to running codemon on current dir

Signed-off-by: Patrik Oldsberg <poldsberg@gmail.com>
This commit is contained in:
Patrik Oldsberg
2021-06-05 18:54:01 +02:00
parent 13711ebed5
commit 49fe0e7391
2 changed files with 6 additions and 4 deletions
+1 -1
View File
@@ -36,7 +36,7 @@ export function createCodemodAction(name: string) {
'--transform',
transformPath,
'--ignore-pattern=**/node_modules/**',
...cmd.args,
...(cmd.args.length ? cmd.args : ['.']),
];
console.log(`Running jscodeshift with these arguments: ${args.join(' ')}`);
+5 -3
View File
@@ -25,12 +25,14 @@ async function main(argv: string[]) {
program.name('backstage-codemods').version(version);
const applyCommand = program
.command('apply <codemod> <target-dirs...>')
.description('Apply a codemod to target directories');
.command('apply <codemod> [<target-dirs...>]')
.description(
'Apply a codemod to target directories, defaulting to the current directory',
);
for (const codemod of codemods) {
applyCommand
.command(`${codemod.name} <target-dirs...>`)
.command(`${codemod.name} [<target-dirs...>]`)
.description(codemod.description)
.option('-d, --dry', 'Dry run, no changes written to files')
.action(createCodemodAction(codemod.name));