mirror of
https://github.com/zhigang1992/react-native.git
synced 2026-04-28 20:25:33 +08:00
Hide npm output when doing react-native init
This commit is contained in:
21
react-native-cli/index.js
vendored
21
react-native-cli/index.js
vendored
@@ -6,7 +6,7 @@
|
|||||||
|
|
||||||
var fs = require('fs');
|
var fs = require('fs');
|
||||||
var path = require('path');
|
var path = require('path');
|
||||||
var spawn = require('child_process').spawn;
|
var exec = require('child_process').exec;
|
||||||
var prompt = require("prompt");
|
var prompt = require("prompt");
|
||||||
|
|
||||||
var CLI_MODULE_PATH = function() {
|
var CLI_MODULE_PATH = function() {
|
||||||
@@ -131,8 +131,11 @@ function createProject(name) {
|
|||||||
fs.writeFileSync(path.join(root, 'package.json'), JSON.stringify(packageJson));
|
fs.writeFileSync(path.join(root, 'package.json'), JSON.stringify(packageJson));
|
||||||
process.chdir(root);
|
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) {
|
if (e) {
|
||||||
|
console.log(stdout);
|
||||||
|
console.error(stderr);
|
||||||
console.error('`npm install --save react-native` failed');
|
console.error('`npm install --save react-native` failed');
|
||||||
process.exit(1);
|
process.exit(1);
|
||||||
}
|
}
|
||||||
@@ -141,17 +144,3 @@ function createProject(name) {
|
|||||||
cli.init(root, projectName);
|
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);
|
|
||||||
}
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|||||||
Reference in New Issue
Block a user