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
This commit is contained in:
Shawn Wilsher
2016-04-29 09:24:27 -07:00
committed by Facebook Github Bot 1
parent 850befa3cd
commit 856f9e9fed
2 changed files with 24 additions and 0 deletions

View File

@@ -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, ''],
};

View File

@@ -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;