Skip to content

Commit

Permalink
refactor: make codemod accept only one directory or file per run
Browse files Browse the repository at this point in the history
  • Loading branch information
massao committed Jun 17, 2024
1 parent cec812d commit 10f610a
Showing 1 changed file with 12 additions and 15 deletions.
27 changes: 12 additions & 15 deletions packages/forma-36-codemod/bin/cli.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -136,6 +136,7 @@ export function run() {
type: 'list',
name: 'setup',
message: `Which codemod you would like to use?`,
when: false,
pageSize: inquirerChoices.SETUP_CHOICES.length,
choices: inquirerChoices.SETUP_CHOICES,
},
Expand All @@ -162,26 +163,22 @@ export function run() {
const { files, parser, setup } = answers;

const filesBeforeExpansion = path || files;
const filesExpanded = expandFilePathsIfNeeded(
filesBeforeExpansion.split(' '),
);
const filesExpanded = expandFilePathsIfNeeded([filesBeforeExpansion]);
const selectedParser = cli.flags.parser || parser;

if (!filesExpanded.length) {
console.log(
`No files found matching ${filesBeforeExpansion.join(' ')}`,
);
console.log(`No files found matching ${filesBeforeExpansion}`);
return null;
}

if (setup === 'v5/icons') {
await updateDependencies(filesBeforeExpansion);
return runTransform({
files: filesExpanded,
flags: cli.flags,
parser: selectedParser,
transformer: 'v5/icons',
});
}
// if (setup === 'v5/icons') {
await updateDependencies(filesBeforeExpansion);
return runTransform({
files: filesExpanded,
flags: cli.flags,
parser: selectedParser,
transformer: 'v5/icons',
});
// }
});
}

0 comments on commit 10f610a

Please sign in to comment.