Skip to content

Commit 949b38a

Browse files
author
Robert Jackson
committed
Resolve jscodeshift binary path manually.
In some circumstances the `jscodeshift` binary is not found by `execa` (e.g. when using `npx`). This changes things around to manually resolve the binary path and use it directly.
1 parent 833662c commit 949b38a

1 file changed

Lines changed: 5 additions & 1 deletion

File tree

src/bin-support.js

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,11 @@ function runTransform(binRoot, transformName, paths) {
1010
.then(paths => {
1111
let transformPath = path.join(binRoot, '..', 'transforms', transformName, 'index.js');
1212

13-
return execa('jscodeshift', ['-t', transformPath, '--extensions', 'js,ts', ...paths], {
13+
let jscodeshiftPkg = require('jscodeshift/package');
14+
let jscodeshiftPath = path.dirname(require.resolve('jscodeshift/package'));
15+
let binPath = path.join(jscodeshiftPath, jscodeshiftPkg.bin.jscodeshift);
16+
17+
return execa(binPath, ['-t', transformPath, '--extensions', 'js,ts', ...paths], {
1418
stdio: 'inherit',
1519
});
1620
})

0 commit comments

Comments
 (0)