From 856f9e9fed8df05b7b36a584217a2ba8d7d8f853 Mon Sep 17 00:00:00 2001 From: Shawn Wilsher Date: Fri, 29 Apr 2016 09:24:27 -0700 Subject: [PATCH] Add `--version` to `local-cli/cli.js` Summary: [Buck](https://buckbuild.com) has a concept of a versioned tool. In order to properly use RN with Buck, the `cli.js` script should return the proper version when passed `--version`. Reviewed By: astreet Differential Revision: D3197207 fb-gh-sync-id: 12ea35587cf492eb89d7dd102e93bdd26bc813c0 fbshipit-source-id: 12ea35587cf492eb89d7dd102e93bdd26bc813c0 --- local-cli/cli.js | 2 ++ local-cli/version/version.js | 22 ++++++++++++++++++++++ 2 files changed, 24 insertions(+) create mode 100644 local-cli/version/version.js diff --git a/local-cli/cli.js b/local-cli/cli.js index 6de43c546..a1418cd25 100644 --- a/local-cli/cli.js +++ b/local-cli/cli.js @@ -30,6 +30,7 @@ var TerminalAdapter = require('yeoman-environment/lib/adapter.js'); var yeoman = require('yeoman-environment'); var unbundle = require('./bundle/unbundle'); var upgrade = require('./upgrade/upgrade'); +var version = require('./version/version'); var fs = require('fs'); var gracefulFs = require('graceful-fs'); @@ -56,6 +57,7 @@ Object.keys(documentedCommands).forEach(function(command) { }); var undocumentedCommands = { + '--version': [version, ''], 'init': [printInitWarning, ''], }; diff --git a/local-cli/version/version.js b/local-cli/version/version.js new file mode 100644 index 000000000..523172e5e --- /dev/null +++ b/local-cli/version/version.js @@ -0,0 +1,22 @@ +/** + * Copyright (c) 2015-present, Facebook, Inc. + * All rights reserved. + * + * This source code is licensed under the BSD-style license found in the + * LICENSE file in the root directory of this source tree. An additional grant + * of patent rights can be found in the PATENTS file in the same directory. + */ +'use strict'; + +var pkg = require('../../package'); +var Promise = require('promise'); + +/** + * Prints the version of react-native and exits. + */ +function version(argv, config) { + console.log(pkg.version); + return Promise.resolve(); +} + +module.exports = version;