Skip to content

Commit

Permalink
Avoid falling back to nonexistent root lockfile
Browse files Browse the repository at this point in the history
  • Loading branch information
ghengeveld committed Oct 9, 2023
1 parent 0b2e0ee commit 9499d59
Showing 1 changed file with 8 additions and 5 deletions.
13 changes: 8 additions & 5 deletions node-src/lib/findChangedDependencies.ts
Original file line number Diff line number Diff line change
Expand Up @@ -40,18 +40,21 @@ export const findChangedDependencies = async (ctx: Context) => {

// Handle monorepos with (multiple) nested package.json files.
const nestedManifestPaths = await findFiles(`**/${PACKAGE_JSON}`);
const pathPairs = await Promise.all(
nestedManifestPaths.map(async (manifestPath) => {
let pathPairs = await Promise.all(
nestedManifestPaths.map(async (manifestPath: string) => {
const dirname = path.dirname(manifestPath);
const [lockfilePath] = await findFiles(
// Fall back to the root lockfile if we can't find one in the same directory.
const [lockfilePath = rootLockfilePath] = await findFiles(
`${dirname}/${YARN_LOCK}`,
`${dirname}/${PACKAGE_LOCK}`
);
// Fall back to the root lockfile if we can't find one in the same directory.
return [manifestPath, lockfilePath || rootLockfilePath];
return lockfilePath && [manifestPath, lockfilePath];
})
);

// Deal with missing rootLockfilePath which may have been used as fallback.
pathPairs = pathPairs.filter(Boolean);

if (rootManifestPath && rootLockfilePath) {
pathPairs.unshift([rootManifestPath, rootLockfilePath]);
} else if (!pathPairs.length) {
Expand Down

0 comments on commit 9499d59

Please sign in to comment.