-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Fix Windows not being able to run
jscodeshift
(#4)
Fix Windows not being able to run `jscodeshift`
- Loading branch information
Showing
1 changed file
with
7 additions
and
4 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,14 +1,17 @@ | ||
#!/usr/bin/env node | ||
|
||
const { spawn } = require('child_process'); | ||
const { execFileSync } = require('child_process'); | ||
const commandExists = require('command-exists'); | ||
|
||
if (!commandExists.sync('jscodeshift')) { | ||
return console.log('Please run `yarn global add jscodeshift` first.'); | ||
} | ||
|
||
const codemod = spawn('jscodeshift', ['-t', __dirname + '/../src/codemod.js', ...process.argv.slice(2)]); | ||
const isPlatformWindows = process.platform === 'win32'; | ||
|
||
codemod.stdout.on('data', data => console.log(data.toString())); | ||
execFileSync('jscodeshift', ['-t', __dirname + '/../src/codemod.js', ...process.argv.slice(2)], { | ||
stdio: [process.stdin, process.stdout, process.stderr], | ||
shell: isPlatformWindows, | ||
}); | ||
|
||
codemod.on('close', () => require('../src/showPackagesToInstall')); | ||
require('../src/showPackagesToInstall'); |