From 2ddf3d942dc080264bf5f17c1381e7e5f39e2f4f Mon Sep 17 00:00:00 2001 From: Alex Kotliarskyi Date: Fri, 7 Aug 2015 10:59:59 -0700 Subject: [PATCH] Hide npm output when doing react-native init --- react-native-cli/index.js | 21 +++++---------------- 1 file changed, 5 insertions(+), 16 deletions(-) diff --git a/react-native-cli/index.js b/react-native-cli/index.js index d8dc54757..d80c7b766 100755 --- a/react-native-cli/index.js +++ b/react-native-cli/index.js @@ -6,7 +6,7 @@ var fs = require('fs'); var path = require('path'); -var spawn = require('child_process').spawn; +var exec = require('child_process').exec; var prompt = require("prompt"); var CLI_MODULE_PATH = function() { @@ -131,8 +131,11 @@ function createProject(name) { fs.writeFileSync(path.join(root, 'package.json'), JSON.stringify(packageJson)); process.chdir(root); - run('npm install --save react-native', function(e) { + console.log('Installing react-native package from npm...'); + exec('npm install --save react-native', function(e, stdout, stderr) { if (e) { + console.log(stdout); + console.error(stderr); console.error('`npm install --save react-native` failed'); process.exit(1); } @@ -141,17 +144,3 @@ function createProject(name) { cli.init(root, projectName); }); } - -function run(command, cb) { - var parts = command.split(/\s+/); - var cmd = parts[0]; - var args = parts.slice(1); - var proc = spawn(cmd, args, {stdio: 'inherit'}); - proc.on('close', function(code) { - if (code !== 0) { - cb(new Error('Command exited with a non-zero status')); - } else { - cb(null); - } - }); -}