Skip to content

Commit d8bae0c

Browse files
committed
Fix Rush linking on pnpm 4
1 parent 0c285cd commit d8bae0c

2 files changed

Lines changed: 28 additions & 6 deletions

File tree

‎.gitignore‎

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,9 @@ yarn-error.log*
99
*.seed
1010
*.pid.lock
1111

12+
# Visual Studio Code
13+
.vscode
14+
1215
# Directory for instrumented libs generated by jscoverage/JSCover
1316
lib-cov
1417

‎apps/rush-lib/src/logic/pnpm/PnpmLinkManager.ts‎

Lines changed: 25 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ import * as os from 'os';
55
import * as path from 'path';
66
import uriEncode = require('strict-uri-encode');
77
import pnpmLinkBins from '@pnpm/link-bins';
8+
import * as semver from 'semver';
89

910
import {
1011
JsonFile,
@@ -30,6 +31,10 @@ import { PnpmShrinkwrapFile } from './PnpmShrinkwrapFile';
3031
const DEBUG: boolean = false;
3132

3233
export class PnpmLinkManager extends BaseLinkManager {
34+
35+
private readonly _pnpmVersion: semver.SemVer
36+
= new semver.SemVer(this._rushConfiguration.packageManagerToolVersion);
37+
3338
protected _linkProjects(): Promise<void> {
3439
try {
3540
const rushLinkJson: IRushLinkJson = {
@@ -200,12 +205,8 @@ export class PnpmLinkManager extends BaseLinkManager {
200205

201206
// tslint:disable-next-line:max-line-length
202207
// e.g.: C:\wbt\common\temp\node_modules\.local\C%3A%2Fwbt%2Fcommon%2Ftemp%2Fprojects%2Fapi-documenter.tgz\node_modules
203-
const pathToLocalInstallation: string = path.join(
204-
this._rushConfiguration.commonTempFolder,
205-
RushConstants.nodeModulesFolderName,
206-
'.local',
207-
folderNameInLocalInstallationRoot,
208-
RushConstants.nodeModulesFolderName);
208+
209+
const pathToLocalInstallation: string = this.GetPathToLocalInstallation(folderNameInLocalInstallationRoot);
209210

210211
for (const dependencyName of Object.keys(commonPackage.packageJson!.dependencies || {})) {
211212
// the dependency we are looking for should have already created a symlink here
@@ -269,4 +270,22 @@ export class PnpmLinkManager extends BaseLinkManager {
269270
return pnpmLinkBins(projectFolder, projectBinFolder)
270271
.then(() => { /* empty block */ });
271272
}
273+
274+
private GetPathToLocalInstallation(folderNameInLocalInstallationRoot: string): string {
275+
if (this._pnpmVersion.major >= 4) {
276+
return path.join(this._rushConfiguration.commonTempFolder,
277+
RushConstants.nodeModulesFolderName,
278+
'.pnpm',
279+
'local',
280+
folderNameInLocalInstallationRoot,
281+
RushConstants.nodeModulesFolderName);
282+
}
283+
else {
284+
return path.join(this._rushConfiguration.commonTempFolder,
285+
RushConstants.nodeModulesFolderName,
286+
'.local',
287+
folderNameInLocalInstallationRoot,
288+
RushConstants.nodeModulesFolderName);
289+
}
290+
}
272291
}

0 commit comments

Comments
 (0)