Skip to content

Commit

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

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

// 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 0e4f407

Please sign in to comment.