Skip to content

Commit

Permalink
Add --version to local-cli/cli.js
Browse files Browse the repository at this point in the history
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
  • Loading branch information
sdwilsh authored and Facebook Github Bot 1 committed Apr 29, 2016
1 parent 850befa commit 856f9e9
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 0 deletions.
2 changes: 2 additions & 0 deletions local-cli/cli.js
Original file line number Diff line number Diff line change
Expand Up @@ -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');
Expand All @@ -56,6 +57,7 @@ Object.keys(documentedCommands).forEach(function(command) {
});

var undocumentedCommands = {
'--version': [version, ''],
'init': [printInitWarning, ''],
};

Expand Down
22 changes: 22 additions & 0 deletions local-cli/version/version.js
Original file line number Diff line number Diff line change
@@ -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;

0 comments on commit 856f9e9

Please sign in to comment.