Skip to content

Commit

Permalink
Merge pull request facebook#2573 from nsimmons/cli/add_version_argument
Browse files Browse the repository at this point in the history
[CLI] Add version argument
  • Loading branch information
frantic committed Sep 10, 2015
2 parents 5ac1c26 + 4f89c61 commit 65c4088
Showing 1 changed file with 15 additions and 3 deletions.
18 changes: 15 additions & 3 deletions react-native-cli/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,12 @@
* Copyright 2004-present Facebook. All Rights Reserved.
*/

'use strict';

var fs = require('fs');
var path = require('path');
var exec = require('child_process').exec;
var prompt = require("prompt");
var prompt = require('prompt');

var CLI_MODULE_PATH = function() {
return path.resolve(
Expand All @@ -18,6 +20,8 @@ var CLI_MODULE_PATH = function() {
);
};

checkForVersionArgument();

var cli;
try {
cli = require(CLI_MODULE_PATH());
Expand Down Expand Up @@ -80,7 +84,7 @@ function init(name) {
validatePackageName(name);

if (fs.existsSync(name)) {
createAfterConfirmation(name)
createAfterConfirmation(name);
} else {
createProject(name);
}
Expand Down Expand Up @@ -140,7 +144,15 @@ function createProject(name) {
process.exit(1);
}

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

function checkForVersionArgument() {
if (process.argv.indexOf('-v') >= 0 || process.argv.indexOf('--version') >= 0) {
var pjson = require('./package.json');
console.log(pjson.version);
process.exit();
}
}

0 comments on commit 65c4088

Please sign in to comment.