Skip to content

Commit

Permalink
Simplify relative path check
Browse files Browse the repository at this point in the history
  • Loading branch information
0x80 committed Jun 11, 2024
1 parent e2e6758 commit 81bb662
Showing 1 changed file with 10 additions and 10 deletions.
20 changes: 10 additions & 10 deletions src/lib/lockfile/helpers/pnpm-map-importer.ts
Original file line number Diff line number Diff line change
Expand Up @@ -45,17 +45,17 @@ function pnpmMapDependenciesLinks(
directoryByPackageName: { [packageName: string]: string }
): ResolvedDependencies {
return mapValues(def, (value, key) => {
if (value.startsWith("link:")) {
let relativePath = path.relative(
importerPath,
directoryByPackageName[key]
);
if (!relativePath.startsWith(".") && !relativePath.startsWith("/")) {
relativePath = `./${relativePath}`;
}
return `link:${relativePath}`;
} else {
if (!value.startsWith("link:")) {
return value;
}

const relativePath = path.relative(
importerPath,
directoryByPackageName[key]
);

return relativePath.startsWith(".")
? `link:${relativePath}`
: `link:./${relativePath}`;
});
}

0 comments on commit 81bb662

Please sign in to comment.