This repository was archived by the owner on Oct 11, 2024. It is now read-only.
Commit cc1f5c5 1 parent e695551 commit cc1f5c5 Copy full SHA for cc1f5c5
File tree 1 file changed +31
-1
lines changed
1 file changed +31
-1
lines changed Original file line number Diff line number Diff line change @@ -9,11 +9,41 @@ const minimatch = require("minimatch");
9
9
10
10
const isCI = ! ! process . env . CI ;
11
11
12
+ // Supports workspaces using nohoist
13
+ // https://classic.yarnpkg.com/blog/2018/02/15/nohoist/
14
+ const getYarnPackages = ( workspaces ) => {
15
+ // No workspaces
16
+ if ( ! workspaces ) {
17
+ return [ ] ;
18
+ }
19
+
20
+ try {
21
+ // "workspaces": ["packages/*"],
22
+ if ( Array . isArray ( workspaces ) ) {
23
+ return workspaces ;
24
+ }
25
+
26
+ // "workspaces": {
27
+ // "packages": ["packages/*"],
28
+ // },
29
+ if ( Array . isArray ( workspaces . packages ) ) {
30
+ return workspaces . packages ;
31
+ }
32
+ } catch ( e ) {
33
+ // Ignore, returns empty array below
34
+ }
35
+
36
+ // Invalid format
37
+ return [ ] ;
38
+ } ;
39
+
12
40
const pkg = importCwd ( "./package.json" ) ;
13
41
const findPkgs = ( g ) => globby . sync ( `${ g } /package.json` ) ;
14
42
const reducePkgs = ( acc , curr ) => acc . concat ( curr . map ( ( c ) => c . slice ( 0 , - 13 ) ) ) ;
15
43
const lerna = importCwd . silent ( "./lerna.json" ) ;
16
- const workspaces = ( pkg . workspaces || [ ] ) . map ( findPkgs ) . reduce ( reducePkgs , [ ] ) ;
44
+ const workspaces = getYarnPackages ( pkg . workspaces )
45
+ . map ( findPkgs )
46
+ . reduce ( reducePkgs , [ ] ) ;
17
47
const lernaPackages = ( ( lerna && lerna . packages ) || [ ] )
18
48
. map ( findPkgs )
19
49
. reduce ( reducePkgs , [ ] ) ;
You can’t perform that action at this time.
0 commit comments