Skip to content

Commit

Permalink
CLI: Refactor printing of version a bit
Browse files Browse the repository at this point in the history
Summary:
Small renaming after facebook#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
  • Loading branch information
Martin Konicek authored and facebook-github-bot committed Dec 16, 2016
1 parent 0579efe commit c4abd5b
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 11 deletions.
21 changes: 11 additions & 10 deletions react-native-cli/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down Expand Up @@ -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();
}
2 changes: 1 addition & 1 deletion react-native-cli/package.json
Original file line number Diff line number Diff line change
@@ -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",
Expand Down

0 comments on commit c4abd5b

Please sign in to comment.