Skip to content

Commit

Permalink
Fix Windows not being able to run jscodeshift (#4)
Browse files Browse the repository at this point in the history
Fix Windows not being able to run `jscodeshift`
  • Loading branch information
Lucas Bento authored May 8, 2019
2 parents 9ae0cae + 180c7b5 commit c780efd
Showing 1 changed file with 7 additions and 4 deletions.
11 changes: 7 additions & 4 deletions bin/rn-update-deprecated-modules
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');

0 comments on commit c780efd

Please sign in to comment.