@@ -44,7 +44,11 @@ const dependsOn = (name, pkg) => {
44
44
* @param {string } targetDir
45
45
*/
46
46
const isMonoRepo = ( targetDir ) => {
47
- return fs . existsSync ( path . join ( targetDir , 'lerna.json' ) )
47
+ const modulePkgPath = path . join ( targetDir , 'package.json' )
48
+ const modulePkg = fs . readJSONSync ( modulePkgPath )
49
+
50
+ // monorepos declare workspaces in their root package.json
51
+ return Boolean ( modulePkg . workspaces )
48
52
}
49
53
50
54
/**
@@ -185,32 +189,15 @@ const testRepo = async (targetDir, deps, scriptName) => {
185
189
const testMonoRepo = async ( targetDir , deps , scriptName ) => {
186
190
await installDependencies ( targetDir )
187
191
188
- let lerna = path . join ( 'node_modules' , '.bin' , 'lerna' )
189
-
190
- if ( ! fs . existsSync ( lerna ) ) {
191
- // no lerna in project dependencies :(
192
- await exec ( 'npm' , [ 'install' , '-g' , 'lerna' ] , {
193
- cwd : targetDir
194
- } )
195
- lerna = 'lerna'
196
- }
197
-
198
- await exec ( lerna , [ 'bootstrap' ] , {
199
- cwd : targetDir
200
- } )
201
-
202
192
// read package targetDir config
203
- const config = await fs . readJSON ( path . join ( targetDir , 'lerna.json' ) )
204
-
205
- // find where the packages are stored
206
- let packages = config . packages || 'packages'
193
+ const config = await fs . readJSON ( path . join ( targetDir , 'package.json' ) )
207
194
208
- if ( ! Array . isArray ( packages ) ) {
209
- packages = [ packages ]
195
+ if ( config . workspaces == null ) {
196
+ throw new Error ( 'Package config did not contain workspaces' )
210
197
}
211
198
212
- // test each package that depends on ipfs/http client
213
- for ( const pattern of packages ) {
199
+ // test each package that depends on passed deps
200
+ for ( const pattern of config . workspaces ) {
214
201
for await ( const match of glob ( targetDir , pattern ) ) {
215
202
await testModule ( path . join ( targetDir , match ) , deps , scriptName )
216
203
}
0 commit comments