Skip to content

Commit

Permalink
Merge pull request #21180 from storybookjs/fix-jscodeshift
Browse files Browse the repository at this point in the history
CLI: Fix jscodeshift error: env: node\r: No such file or directory
  • Loading branch information
shilman authored Feb 21, 2023
2 parents 5ec17dc + 5ac3b94 commit f523641
Showing 1 changed file with 8 additions and 3 deletions.
11 changes: 8 additions & 3 deletions code/lib/codemod/src/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -55,12 +55,17 @@ export async function runCodemod(codemod, { glob, logger, dryRun, rename, parser

const files = await globby([glob, '!**/node_modules', '!**/dist']);
logger.log(`=> Applying ${codemod}: ${files.length} files`);
if (!dryRun) {
if (files.length === 0) {
logger.log(`=> No matching files for glob: ${glob}`);
return;
}

if (!dryRun && files.length > 0) {
const parserArgs = inferredParser ? ['--parser', inferredParser] : [];
spawnSync(
'npx',
'node',
[
'jscodeshift',
require.resolve('jscodeshift/bin/jscodeshift'),
// this makes sure codeshift doesn't transform our own source code with babel
// which is faster, and also makes sure the user won't see babel messages such as:
// [BABEL] Note: The code generator has deoptimised the styling of repo/node_modules/prettier/index.js as it exceeds the max of 500KB.
Expand Down

0 comments on commit f523641

Please sign in to comment.