@@ -10,6 +10,8 @@ const {
1010 wrapAsync,
1111 writeJsonAsync,
1212 getJSONKey,
13+ resolveFileInPackage,
14+ resolveDirInPackage,
1315} = require ( './utils' ) ;
1416
1517// https://github.com/TehShrike/deepmerge#overwrite-array
@@ -31,7 +33,7 @@ const installEdition = (edition, config, projectDir) => {
3133 const sourceDir = config . paths . source . root ;
3234 yield checkAndInstallPackage ( edition ) ; // 1
3335 yield copyAsync (
34- path . resolve ( './node_modules' , edition , 'source' , '_meta' ) ,
36+ resolveDirInPackage ( edition , 'source' , '_meta' ) ,
3537 path . resolve ( sourceDir , '_meta' )
3638 ) ; // 2
3739 pkg . dependencies = Object . assign (
@@ -45,16 +47,15 @@ const installEdition = (edition, config, projectDir) => {
4547 // 4.1
4648 case '@pattern-lab/edition-node-gulp' : {
4749 yield copyAsync (
48- path . resolve ( './node_modules' , edition , 'gulpfile.js' ) ,
50+ resolveFileInPackage ( edition , 'gulpfile.js' ) ,
4951 path . resolve ( sourceDir , '../' , 'gulpfile.js' )
5052 ) ;
5153 break ;
5254 }
5355 // 4.2
5456 case '@pattern-lab/edition-node' : {
55- const editionPath = path . resolve ( './node_modules' , edition ) ;
56- const editionConfigPath = path . resolve (
57- editionPath ,
57+ const editionConfigPath = resolveFileInPackage (
58+ edition ,
5859 'patternlab-config.json'
5960 ) ;
6061
@@ -67,7 +68,7 @@ const installEdition = (edition, config, projectDir) => {
6768 ) ;
6869
6970 yield copyAsync (
70- path . join ( editionPath , path . sep , 'helpers' , path . sep , 'test.js' ) ,
71+ resolveFileInPackage ( edition , 'helpers' , 'test.js' ) ,
7172 path . resolve ( sourceDir , '../' , 'helpers/test.js' )
7273 ) ;
7374
@@ -76,9 +77,8 @@ const installEdition = (edition, config, projectDir) => {
7677 }
7778 // 4.3
7879 case '@pattern-lab/edition-twig' : {
79- const editionPath = path . resolve ( './node_modules' , edition ) ;
80- const editionConfigPath = path . resolve (
81- editionPath ,
80+ const editionConfigPath = resolveFileInPackage (
81+ edition ,
8282 'patternlab-config.json'
8383 ) ;
8484 const editionConfig = require ( editionConfigPath ) ;
@@ -90,7 +90,7 @@ const installEdition = (edition, config, projectDir) => {
9090 ) ;
9191
9292 yield copyAsync (
93- path . resolve ( editionPath , 'alter-twig.php' ) ,
93+ resolveFileInPackage ( edition , 'alter-twig.php' ) ,
9494 path . resolve ( sourceDir , '../' , 'alter-twig.php' )
9595 ) ;
9696
0 commit comments