Skip to content
Snippets Groups Projects
Unverified Commit c2590a56 authored by Rhys Arkins's avatar Rhys Arkins Committed by GitHub
Browse files

feat: support multiple yarn workspaces in one repository (#1264)

parent d56654cd
No related branches found
No related tags found
No related merge requests found
......@@ -8,32 +8,36 @@ module.exports = {
async function checkMonorepos(config) {
const monorepoPackages = [];
let workspaceDir;
logger.debug('checkMonorepos()');
logger.trace({ config });
// yarn workspaces
let workspaces = [];
for (const packageFile of config.packageFiles) {
if (
packageFile.packageFile &&
packageFile.packageFile.endsWith('package.json') &&
packageFile.content.workspaces
) {
workspaceDir = path.dirname(packageFile.packageFile);
logger.info(`workspaceDir=${config.workspaceDir}`);
({ workspaces } = packageFile.content);
}
}
if (workspaces.length) {
logger.debug({ workspaces }, 'Found yarn workspaces');
}
for (const workspace of workspaces) {
const basePath = upath.join(workspaceDir, workspace);
logger.info(`basePath=${basePath}`);
for (const packageFile of config.packageFiles) {
if (minimatch(path.dirname(packageFile.packageFile), basePath)) {
logger.info(`Matched ${packageFile.packageFile}`);
const depName = packageFile.content.name;
monorepoPackages.push(depName);
packageFile.workspaceDir = workspaceDir;
const workspaceDir = path.dirname(packageFile.packageFile);
const { workspaces } = packageFile.content;
if (workspaces.length) {
logger.info(
{ packageFile: packageFile.packageFile, workspaces },
'Found yarn workspaces'
);
for (const workspace of workspaces) {
const basePath = upath.join(workspaceDir, workspace);
logger.debug(`basePath=${basePath}`);
for (const innerPackageFile of config.packageFiles) {
if (
minimatch(path.dirname(innerPackageFile.packageFile), basePath)
) {
logger.debug(`Matched ${innerPackageFile.packageFile}`);
const depName = innerPackageFile.content.name;
monorepoPackages.push(depName);
innerPackageFile.workspaceDir = workspaceDir;
}
}
}
}
}
}
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment