CLI: Refactor printing of version a bit

Summary:
Small renaming after https://github.com/facebook/react-native/pull/11464

**Test plan**

Ran 'react-native init' and 'react-native -v' inside and outside a RN project.

Reviewed By: mkonicek

Differential Revision:
D4339481
Ninja: OSS only

fbshipit-source-id: b23daaee55907761ed0820a707f36ad70d1f1d09
This commit is contained in:
Martin Konicek 2016-12-16 06:41:38 -08:00 committed by Facebook Github Bot
parent 0579efea8c
commit c4abd5b82a
2 changed files with 12 additions and 11 deletions

View File

@ -74,7 +74,10 @@ var REACT_NATIVE_PACKAGE_JSON_PATH = function() {
'package.json'
);
};
checkForVersionArgument(options);
if (options._.length === 0 && (options.v || options.version)) {
printVersionsAndExit(REACT_NATIVE_PACKAGE_JSON_PATH());
}
// Use Yarn if available, it's much faster than the npm client.
// Return the version of yarn installed on the system, null if yarn is not available.
@ -315,14 +318,12 @@ function checkNodeVersion() {
}
}
function checkForVersionArgument(options) {
if (options._.length === 0 && (options.v || options.version)) {
console.log('react-native-cli: ' + require('./package.json').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();
function printVersionsAndExit(reactNativePackageJsonPath) {
console.log('react-native-cli: ' + require('./package.json').version);
try {
console.log('react-native: ' + require(reactNativePackageJsonPath).version);
} catch (e) {
console.log('react-native: n/a - not inside a React Native project directory');
}
process.exit();
}

View File

@ -1,6 +1,6 @@
{
"name": "react-native-cli",
"version": "2.0.0",
"version": "2.0.1",
"license": "BSD-3-Clause",
"description": "The React Native CLI tools",
"main": "index.js",