Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
19 changes: 18 additions & 1 deletion scripts/gather-licenses.ts
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,24 @@ export async function gatherLicenses(startPath: string): Promise<Package[]> {
}
throw new Error(`Could not resolve ${dep} require from ${pkg.path}`);
}
const pkgJson = await pkgUp({ cwd: path.dirname(resolved) });
const pkgJson = await findUp(
async (directory) => {
const candidate = path.join(directory, 'package.json');
try {
const { name, version } = require(candidate);
// Make sure that package.json that we found has the bare
// minimum of required package.json keys
if (name && version) {
return candidate;
}
} catch (e) {
// Ignore errors, just return undefined to continue
// traversal
}
return undefined;
},
{ cwd: path.dirname(resolved) }
);
if (!pkgJson) {
throw new Error(`Could not find package.json for ${dep} required from ${pkg.path}`);
}
Expand Down