Skip to content

Commit 26beba7

Browse files
authored
refactor(nm): return object with linkType and target (#4143)
* refactor(nm): use const for linkType and target * yarn version check --interactive * fix: populate linkType and target as a tuple * chore: return object containing linkType and target
1 parent ee2cf8f commit 26beba7

File tree

2 files changed

+9
-10
lines changed

2 files changed

+9
-10
lines changed

.yarn/versions/5f099b36.yml

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
releases:
2+
"@yarnpkg/nm": patch
3+
4+
declined:
5+
- "@yarnpkg/plugin-nm"
6+
- "@yarnpkg/pnpify"

packages/yarnpkg-nm/sources/buildNodeModulesTree.ts

Lines changed: 3 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -463,21 +463,14 @@ function getTargetLocatorPath(locator: PhysicalPackageLocator, pnp: PnpApi, opti
463463
if (info === null)
464464
throw new Error(`Assertion failed: Expected the package to be registered`);
465465

466-
let linkType;
467-
let target;
468-
if (options.pnpifyFs) {
466+
return options.pnpifyFs
469467
// In case of pnpifyFs we represent modules as symlinks to archives in NodeModulesFS
470468
// `/home/user/project/foo` is a symlink to `/home/user/project/.yarn/.cache/foo.zip/node_modules/foo`
471469
// To make this fs layout work with legacy tools we make
472470
// `/home/user/project/.yarn/.cache/foo.zip/node_modules/foo/node_modules` (which normally does not exist inside archive) a symlink to:
473471
// `/home/user/project/node_modules/foo/node_modules`, so that the tools were able to access it
474-
target = npath.toPortablePath(info.packageLocation);
475-
linkType = LinkType.SOFT;
476-
} else {
477-
target = getRealPackageLocation(info, locator, pnp);
478-
linkType = info.linkType;
479-
}
480-
return {linkType, target};
472+
? {linkType: LinkType.SOFT, target: npath.toPortablePath(info.packageLocation)}
473+
: {linkType: info.linkType, target: getRealPackageLocation(info, locator, pnp)};
481474
}
482475

483476
/**

0 commit comments

Comments
 (0)