Skip to content

Commit c4abd5b

Browse files
Martin Konicekfacebook-github-bot
authored andcommitted
CLI: Refactor printing of version a bit
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
1 parent 0579efe commit c4abd5b

File tree

2 files changed

+12
-11
lines changed

2 files changed

+12
-11
lines changed

react-native-cli/index.js

Lines changed: 11 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -74,7 +74,10 @@ var REACT_NATIVE_PACKAGE_JSON_PATH = function() {
7474
'package.json'
7575
);
7676
};
77-
checkForVersionArgument(options);
77+
78+
if (options._.length === 0 && (options.v || options.version)) {
79+
printVersionsAndExit(REACT_NATIVE_PACKAGE_JSON_PATH());
80+
}
7881

7982
// Use Yarn if available, it's much faster than the npm client.
8083
// Return the version of yarn installed on the system, null if yarn is not available.
@@ -315,14 +318,12 @@ function checkNodeVersion() {
315318
}
316319
}
317320

318-
function checkForVersionArgument(options) {
319-
if (options._.length === 0 && (options.v || options.version)) {
320-
console.log('react-native-cli: ' + require('./package.json').version);
321-
try {
322-
console.log('react-native: ' + require(REACT_NATIVE_PACKAGE_JSON_PATH()).version);
323-
} catch (e) {
324-
console.log('react-native: n/a - not inside a React Native project directory');
325-
}
326-
process.exit();
321+
function printVersionsAndExit(reactNativePackageJsonPath) {
322+
console.log('react-native-cli: ' + require('./package.json').version);
323+
try {
324+
console.log('react-native: ' + require(reactNativePackageJsonPath).version);
325+
} catch (e) {
326+
console.log('react-native: n/a - not inside a React Native project directory');
327327
}
328+
process.exit();
328329
}

react-native-cli/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "react-native-cli",
3-
"version": "2.0.0",
3+
"version": "2.0.1",
44
"license": "BSD-3-Clause",
55
"description": "The React Native CLI tools",
66
"main": "index.js",

0 commit comments

Comments
 (0)