|
@@ -15,12 +15,24 @@ const backSlash = /\\/g;
|
|
|
*/
|
|
|
export function getLernaPaths(basePath = '.'): string[] {
|
|
|
basePath = path.resolve(basePath);
|
|
|
- let baseConfig = require(path.join(basePath, 'package.json'));
|
|
|
+ let packages;
|
|
|
+ try {
|
|
|
+ let baseConfig = require(path.join(basePath, 'package.json'));
|
|
|
+ if (baseConfig.workspaces) {
|
|
|
+ packages = baseConfig.workspaces.packages || baseConfig.workspaces;
|
|
|
+ } else {
|
|
|
+ baseConfig = require(path.join(basePath, 'lerna.json'));
|
|
|
+ packages = baseConfig.packages;
|
|
|
+ }
|
|
|
+ } catch (e) {
|
|
|
+ if (e.code === 'MODULE_NOT_FOUND') {
|
|
|
+ throw new Error(
|
|
|
+ `No yarn workspace / lerna package list found in ${basePath}`
|
|
|
+ );
|
|
|
+ }
|
|
|
+ throw e;
|
|
|
+ }
|
|
|
let paths: string[] = [];
|
|
|
- let packages =
|
|
|
- baseConfig.workspaces.packages ||
|
|
|
- baseConfig.workspaces ||
|
|
|
- baseConfig.packages;
|
|
|
for (let config of packages) {
|
|
|
paths = paths.concat(glob.sync(path.join(basePath, config)));
|
|
|
}
|