@@ -5,6 +5,7 @@ import * as os from 'os';
55import * as path from 'path' ;
66import uriEncode = require( 'strict-uri-encode' ) ;
77import pnpmLinkBins from '@pnpm/link-bins' ;
8+ import * as semver from 'semver' ;
89
910import {
1011 JsonFile ,
@@ -30,6 +31,10 @@ import { PnpmShrinkwrapFile } from './PnpmShrinkwrapFile';
3031const DEBUG : boolean = false ;
3132
3233export 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