Skip to content

Commit f965533

Browse files
committed
Make the global rush-recycler not node-specific.
1 parent 5759316 commit f965533

3 files changed

Lines changed: 24 additions & 9 deletions

File tree

‎apps/rush-lib/src/api/RushConfiguration.ts‎

Lines changed: 13 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -187,6 +187,7 @@ export class RushConfiguration {
187187
private _tempShrinkwrapFilename: string;
188188
private _tempShrinkwrapPreinstallFilename: string;
189189
private _rushUserFolder: string;
190+
private _versionIndependentRushUserFolder: string;
190191
private _rushLinkJsonFilename: string;
191192
private _currentVariantJsonFilename: string;
192193
private _packageManagerToolVersion: string;
@@ -565,13 +566,21 @@ export class RushConfiguration {
565566
}
566567

567568
/**
568-
* The absolute path to Rush's storage in the home directory for the current user. On Windows,
569-
* it would be something like `C:\Users\YourName\.rush`.
569+
* The absolute path to Rush's storage in the home directory for the current user and node version.
570+
* On Windows, it would be something like `C:\Users\YourName\.rush\node-v4.5.6\`.
570571
*/
571572
public get rushUserFolder(): string {
572573
return this._rushUserFolder;
573574
}
574575

576+
/**
577+
* The absolute path to Rush's storage in the home directory for the current user, independent of node version.
578+
* On Windows, it would be something like `C:\Users\YourName\.rush\`.
579+
*/
580+
public get versionIndependentRushUserFolder(): string {
581+
return this._versionIndependentRushUserFolder;
582+
}
583+
575584
/**
576585
* The filename of the build dependency data file. By default this is
577586
* called 'rush-link.json' resides in the Rush common folder.
@@ -908,7 +917,8 @@ export class RushConfiguration {
908917
this._yarnCacheFolder = path.resolve(path.join(this._commonTempFolder, 'yarn-cache'));
909918

910919
this._changesFolder = path.join(this._commonFolder, RushConstants.changeFilesFolderName);
911-
this._rushUserFolder = path.join(Utilities.getHomeDirectory(), '.rush', `node-${process.version}`);
920+
this._versionIndependentRushUserFolder = path.join(Utilities.getHomeDirectory(), '.rush');
921+
this._rushUserFolder = path.join(this._versionIndependentRushUserFolder, `node-${process.version}`);
912922

913923
this._rushLinkJsonFilename = path.join(this._commonTempFolder, 'rush-link.json');
914924
this._currentVariantJsonFilename = path.join(this._commonTempFolder, 'current-variant.json');

‎apps/rush-lib/src/logic/PurgeManager.ts‎

Lines changed: 10 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -19,12 +19,16 @@ export class PurgeManager {
1919
public constructor(rushConfiguration: RushConfiguration) {
2020
this._rushConfiguration = rushConfiguration;
2121

22-
const commonAsyncRecyclerPath: string = path.join(this._rushConfiguration.commonTempFolder,
23-
RushConstants.rushRecyclerFolderName);
22+
const commonAsyncRecyclerPath: string = path.join(
23+
this._rushConfiguration.commonTempFolder,
24+
RushConstants.rushRecyclerFolderName
25+
);
2426
this._commonTempFolderRecycler = new AsyncRecycler(commonAsyncRecyclerPath);
2527

26-
const rushUserAsyncRecyclerPath: string = path.join(this._rushConfiguration.rushUserFolder,
27-
RushConstants.rushRecyclerFolderName);
28+
const rushUserAsyncRecyclerPath: string = path.join(
29+
this._rushConfiguration.versionIndependentRushUserFolder,
30+
RushConstants.rushRecyclerFolderName
31+
);
2832
this._rushUserFolderRecycler = new AsyncRecycler(rushUserAsyncRecyclerPath);
2933
}
3034

@@ -59,7 +63,7 @@ export class PurgeManager {
5963
public purgeUnsafe(): void {
6064
this.purgeNormal();
6165

62-
// Also delete everything under ~/.rush except for the recycler folder itself
66+
// Also delete everything under ~/.rush/node-v4.5.6/ except for the recycler folder itself
6367
console.log('Purging ' + this._rushConfiguration.rushUserFolder);
6468
this._rushUserFolderRecycler.moveAllItemsInFolder(this._rushConfiguration.rushUserFolder,
6569
this._getMembersToExclude(this._rushConfiguration.rushUserFolder));
@@ -74,7 +78,7 @@ export class PurgeManager {
7478
const currentFolderPath: string = path.resolve(__dirname);
7579

7680
// Example:
77-
// folderToRecycle = "/home/user/.rush"
81+
// folderToRecycle = "/home/user/.rush/node-v4.5.6"
7882
// relative = "rush-1.2.3/lib/example.js"
7983
const relative: string = path.relative(folderToRecycle, currentFolderPath);
8084

‎common/reviews/api/rush-lib.api.ts‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -244,6 +244,7 @@ class RushConfiguration {
244244
readonly tempShrinkwrapPreinstallFilename: string;
245245
static tryFindRushJsonLocation(verbose?: boolean): string | undefined;
246246
tryGetProjectForPath(currentFolderPath: string): RushConfigurationProject | undefined;
247+
readonly versionIndependentRushUserFolder: string;
247248
// @beta (undocumented)
248249
readonly versionPolicyConfiguration: VersionPolicyConfiguration;
249250
readonly yarnCacheFolder: string;

0 commit comments

Comments
 (0)