@@ -8,13 +8,29 @@ const flatten = require('lodash').flatten;
88 * @param {String } dependency Name of the dependency
99 * @return {Boolean } If dependency is a rnpm plugin
1010 */
11- const isPlugin = ( dependency ) => dependency . indexOf ( 'rnpm-plugin-' ) === 0 ;
11+ const isRNPMPlugin = ( dependency ) => dependency . indexOf ( 'rnpm-plugin-' ) === 0 ;
12+ const isReactNativePlugin = ( dependency ) => dependency . indexOf ( 'react-native-' ) === 0 ;
1213
13- const findPluginInFolder = ( folder ) => {
14- var pjson ;
14+ const readPackage = ( folder ) => {
1515 try {
16- pjson = require ( path . join ( folder , 'package.json' ) ) ;
16+ return require ( path . join ( folder , 'package.json' ) ) ;
1717 } catch ( e ) {
18+ return null ;
19+ }
20+ } ;
21+
22+ const findPluginsInReactNativePackage = ( pjson ) => {
23+ if ( ! pjson . rnpm || ! pjson . rnpm . plugin ) {
24+ return [ ] ;
25+ }
26+
27+ return path . join ( pjson . name , pjson . rnpm . plugin ) ;
28+ } ;
29+
30+ const findPluginInFolder = ( folder ) => {
31+ const pjson = readPackage ( folder ) ;
32+
33+ if ( ! pjson ) {
1834 return [ ] ;
1935 }
2036
@@ -23,7 +39,22 @@ const findPluginInFolder = (folder) => {
2339 Object . keys ( pjson . devDependencies || { } )
2440 ) ;
2541
26- return deps . filter ( isPlugin ) ;
42+ return deps . reduce (
43+ ( acc , pkg ) => {
44+ if ( isRNPMPlugin ( pkg ) ) {
45+ return acc . concat ( pkg ) ;
46+ }
47+ if ( isReactNativePlugin ( pkg ) ) {
48+ const pkgJson = readPackage ( path . join ( folder , 'node_modules' , pkg ) ) ;
49+ if ( ! pkgJson ) {
50+ return acc ;
51+ }
52+ return acc . concat ( findPluginsInReactNativePackage ( pkgJson ) ) ;
53+ }
54+ return acc ;
55+ } ,
56+ [ ]
57+ ) ;
2758} ;
2859
2960/**
0 commit comments