add react-native version output for -v/--version

This commit is contained in:
sunnylqm 2015-12-26 22:23:08 +08:00
parent 65a9e505bd
commit 1dea58c7df
1 changed files with 6 additions and 2 deletions

View File

@ -221,8 +221,12 @@ function checkNodeVersion() {
function checkForVersionArgument() { function checkForVersionArgument() {
if (process.argv.indexOf('-v') >= 0 || process.argv.indexOf('--version') >= 0) { if (process.argv.indexOf('-v') >= 0 || process.argv.indexOf('--version') >= 0) {
var pjson = require('./package.json'); console.log('react-native-cli: ' + require('./package.json').version);
console.log(pjson.version); try {
console.log('react-native: ' + require(REACT_NATIVE_PACKAGE_JSON_PATH()).version);
} catch (e) {
console.log('react-native: n/a - not inside a React Native project directory')
}
process.exit(); process.exit();
} }
} }