From 861786686d9e0fccd96719949498ff19bba2c337 Mon Sep 17 00:00:00 2001 From: Eric Rozell Date: Tue, 2 Aug 2016 15:17:44 -0400 Subject: [PATCH] Flattens RNPM user commands from plugin modules 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. --- local-cli/rnpm/core/src/getCommands.js | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/local-cli/rnpm/core/src/getCommands.js b/local-cli/rnpm/core/src/getCommands.js index 0a86b64140f0a6..d406643002cbd8 100644 --- a/local-cli/rnpm/core/src/getCommands.js +++ b/local-cli/rnpm/core/src/getCommands.js @@ -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); };