mirror of
https://github.com/zhigang1992/react-native.git
synced 2026-03-30 17:33:21 +08:00
Flattens RNPM user commands from plugin modules
Summary: RNPM plugins may have ship multiple commands as extensions (e.g., https://github.com/rnpm/rnpm-plugin-link/blob/master/index.js#L1) The consumer of the user commands (https://github.com/facebook/react-native/blob/master/local-cli/commands.js#L67) expects a flat list of commands, which used to be flattened here https://github.com/rnpm/rnpm/blob/master/bin/cli#L35 in RNPM. This commit simply flattens the (possible) set of commands coming out of a user plugin. Closes https://github.com/facebook/react-native/pull/9170 Differential Revision: D3661809 fbshipit-source-id: 72107745e53bf63b47a297eae546ed4a69c57008
This commit is contained in:
committed by
Facebook Github Bot 1
parent
e34dd4f938
commit
de517a84e8
@@ -1,11 +1,12 @@
|
||||
const path = require('path');
|
||||
const findPlugins = require('./findPlugins');
|
||||
const flatten = require('lodash').flatten;
|
||||
|
||||
/**
|
||||
* @return {Array} Array of commands
|
||||
*/
|
||||
module.exports = function getCommands() {
|
||||
const appRoot = process.cwd();
|
||||
|
||||
return findPlugins([appRoot]).map(name => require(path.join(appRoot, 'node_modules', name)));
|
||||
const plugins = findPlugins([appRoot]).map(name => require(path.join(appRoot, 'node_modules', name)));
|
||||
return flatten(plugins);
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user