From dee984d1ddc8e2cdb0eef51bd0470744c92058eb Mon Sep 17 00:00:00 2001 From: DengYun Date: Thu, 7 Jan 2016 11:43:01 +0800 Subject: [PATCH] Do some dirty for windows compatible --- react-native-cli/index.js | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/react-native-cli/index.js b/react-native-cli/index.js index 01c8f0e64..306191bcc 100755 --- a/react-native-cli/index.js +++ b/react-native-cli/index.js @@ -42,6 +42,7 @@ var spawn = require('child_process').spawn; var chalk = require('chalk'); var prompt = require('prompt'); var semver = require('semver'); +var os = require('os'); var CLI_MODULE_PATH = function() { return path.resolve( @@ -198,7 +199,14 @@ function run(root, projectName, logLevel) { if (logLevel === 'debug' || logLevel === 'verbose') { spawnArgs = {stdio: 'inherit'}; } - var proc = spawn('npm', args, spawnArgs); + var proc; + if (os.platform() === 'win32'){ + args.unshift('npm'); + args.unshift('/c'); + proc = spawn('cmd', args, spawnArgs); + } else { + proc = spawn('npm', args, spawnArgs); + } proc.on('close', function (code) { if (code !== 0) { console.error('`npm install --save react-native` failed');