Skip to content

Commit

Permalink
refactor(npm): monorepo upath use
Browse files Browse the repository at this point in the history
  • Loading branch information
rarkins committed Mar 20, 2021
1 parent 460bfe9 commit 7af7d3b
Showing 1 changed file with 3 additions and 8 deletions.
11 changes: 3 additions & 8 deletions lib/manager/npm/extract/monorepo.ts
@@ -1,8 +1,8 @@
import is from '@sindresorhus/is';
import minimatch from 'minimatch';
import upath from 'upath';
import { logger } from '../../../logger';
import { SkipReason } from '../../../types';
import { getSiblingFileName, getSubDirectory } from '../../../util/fs';
import type { PackageFile } from '../../types';

function matchesAnyPattern(val: string, patterns: string[]): boolean {
Expand All @@ -29,20 +29,15 @@ export function detectMonorepos(
yarnWorkspacesPackages,
} = p;
const { lernaJsonFile } = managerData;
const basePath = upath.dirname(packageFile);
const packages = yarnWorkspacesPackages || lernaPackages;
if (packages?.length) {
logger.debug(
{ packageFile, yarnWorkspacesPackages, lernaPackages },
'Found monorepo packages with base path ' + JSON.stringify(basePath)
);
const internalPackagePatterns = (is.array(packages)
? packages
: [packages]
).map((pattern) => upath.join(basePath, pattern));
).map((pattern) => getSiblingFileName(packageFile, pattern));
const internalPackageFiles = packageFiles.filter((sp) =>
matchesAnyPattern(
upath.dirname(sp.packageFile),
getSubDirectory(sp.packageFile),
internalPackagePatterns
)
);
Expand Down

0 comments on commit 7af7d3b

Please sign in to comment.