Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

npm progress shown on react init #4835

Merged
merged 1 commit into from
Dec 22, 2015
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
33 changes: 10 additions & 23 deletions react-native-cli/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -180,37 +180,24 @@ function createProject(name, verbose) {

console.log('Installing react-native package from npm...');

if (verbose) {
runVerbose(root, projectName);
} else {
run(root, projectName);
}
run(root, projectName, verbose);
}

function run(root, projectName) {
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);
}

checkNodeVersion();

var cli = require(CLI_MODULE_PATH());
cli.init(root, projectName);
});
}

function runVerbose(root, projectName) {
var proc = spawn('npm', ['install', '--verbose', '--save', 'react-native'], {stdio: 'inherit'});
function run(root, projectName, verbose) {
var args = ['install', '--save'];
if (verbose){
args.push('--verbose');
}
args.push('react-native');
var proc = spawn('npm', args, {stdio: 'inherit'});
proc.on('close', function (code) {
if (code !== 0) {
console.error('`npm install --save react-native` failed');
return;
}

checkNodeVersion();

cli = require(CLI_MODULE_PATH());
cli.init(root, projectName);
});
Expand Down