From d50c7fd7bebdde8705fcf63d1cfd481a41bc289e Mon Sep 17 00:00:00 2001 From: Kipras Melnikovas Date: Sat, 30 Oct 2021 02:05:50 +0300 Subject: [PATCH] fix standalone transform runs - resolve path of transform MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 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] https://github.com/facebook/jscodeshift/issues/398 [2] https://github.com/CodeshiftCommunity/CodeshiftCommunity/issues/48#issuecomment-955049880 --- packages/cli/src/main.ts | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/packages/cli/src/main.ts b/packages/cli/src/main.ts index 21eeb97d7..ac709c108 100644 --- a/packages/cli/src/main.ts +++ b/packages/cli/src/main.ts @@ -1,3 +1,4 @@ +import path from 'path'; import semver from 'semver'; import chalk from 'chalk'; import path from 'path'; @@ -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,