Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(ui5-tooling-modules): advanced dependency detection #1104

Merged
merged 1 commit into from
Oct 19, 2024
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
12 changes: 11 additions & 1 deletion packages/ui5-tooling-modules/lib/util.js
Original file line number Diff line number Diff line change
Expand Up @@ -170,7 +170,17 @@ const npmPackageScopeRegEx = /^((?:(@[^/]+)\/)?([^/]+))(?:\/(.*))?$/;
function findDependency(dep, cwd = process.cwd(), depPaths = []) {
let modulePath;
try {
modulePath = resolve(dep, { paths: [cwd, ...depPaths] });
try {
modulePath = resolve(dep, { paths: [cwd, ...depPaths] });
} catch (err) {
// sometimes the package.json is not found, therefore we try to resolve the dependency
// without the package.json, just with the npm package name (and lookup the package.json manually)
if (dep.endsWith("/package.json") && err.code === "MODULE_NOT_FOUND") {
modulePath = resolve(dep.substring(0, dep.length - "/package.json".length), { paths: [cwd, ...depPaths] });
} else {
throw err;
}
}
} catch (err) {
// if the module is not exported, we try to resolve it manually
const [, npmPackage, , , module] = npmPackageScopeRegEx.exec(dep) || [];
Expand Down
Loading