Skip to content

Commit

Permalink
fix standalone transform runs - resolve path of transform
Browse files Browse the repository at this point in the history
in the issue you linked [1] from jscodeshift, i think you forgot the `path.resolve` for non-http(s) imports (not even sure how they'd work tbh).

i tried running a local transform and it didn't work, but with this fix it did regardless of where i called the `packages/cli/bin/codeshift-cli.js` from. i think you might've been using the packages and not the --transforms flag so i understand why you could've missed it 😅

tbh there are more improvements to make w/ the local transforms (see [2]) but this is the first step :D

[1] facebook/jscodeshift#398
[2] #48 (comment)
  • Loading branch information
kiprasmel committed Jan 26, 2022
1 parent 4872226 commit d50c7fd
Showing 1 changed file with 4 additions and 2 deletions.
6 changes: 4 additions & 2 deletions packages/cli/src/main.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import path from 'path';
import semver from 'semver';
import chalk from 'chalk';
import path from 'path';
Expand Down Expand Up @@ -215,9 +216,10 @@ Make sure the package name ${pkgName} has been spelled correctly and exists befo
);

for (const transform of transforms) {
console.log(chalk.green('Running transform:'), transform);
const resolvedTransformPath = path.resolve(transform);
console.log(chalk.green('Running transform:'), resolvedTransformPath);

await jscodeshift.run(transform, paths, {
await jscodeshift.run(resolvedTransformPath, paths, {
verbose: 0,
dry: flags.dry,
print: true,
Expand Down

0 comments on commit d50c7fd

Please sign in to comment.