@@ -10,21 +10,24 @@ exports.couldMissGulpPreprocess = function(id) {
10
10
return ext && ext !== '.js' && ext !== '.html' && ext !== '.css' ;
11
11
} ;
12
12
13
- // require.resolve(packageName) cannot resolve package has no main.
14
- // for instance: font-awesome v4.7.0
15
- // manually try resolve paths
16
- const PACKAGE_PATHS = [
17
- // normal search from cli
18
- ...require . resolve . paths ( 'not-core/' ) ,
19
- // additional search from app's folder, this is necessary to support
20
- // lerna hoisting where cli is out of app's local node_modules folder.
21
- ...require ( 'resolve/lib/node-modules-paths' ) ( process . cwd ( ) , { } )
22
- ] ;
13
+ function getPackagePaths ( ) {
14
+ // require.resolve(packageName) cannot resolve package has no main.
15
+ // for instance: font-awesome v4.7.0
16
+ // manually try resolve paths
17
+ return [
18
+ // normal search from cli
19
+ ...require . resolve . paths ( 'not-core/' ) ,
20
+ // additional search from app's folder, this is necessary to support
21
+ // lerna hoisting where cli is out of app's local node_modules folder.
22
+ ...require ( 'resolve/lib/node-modules-paths' ) ( process . cwd ( ) , { } )
23
+ ] ;
24
+ }
23
25
24
26
// resolve npm package path
25
27
exports . resolvePackagePath = function ( packageName ) {
26
- for ( let i = 0 , len = PACKAGE_PATHS . length ; i < len ; i ++ ) {
27
- const dirname = path . join ( PACKAGE_PATHS [ i ] , packageName ) ;
28
+ const packagePaths = getPackagePaths ( ) ;
29
+ for ( let i = 0 , len = packagePaths . length ; i < len ; i ++ ) {
30
+ const dirname = path . join ( packagePaths [ i ] , packageName ) ;
28
31
if ( fs . isDirectory ( dirname ) ) return dirname ;
29
32
}
30
33
0 commit comments