Skip to content

Commit 992c519

Browse files
committed
Refactoring the user folders in rushConfiguration.
1 parent f965533 commit 992c519

4 files changed

Lines changed: 24 additions & 20 deletions

File tree

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

Lines changed: 14 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -186,8 +186,8 @@ export class RushConfiguration {
186186
private _yarnCacheFolder: string;
187187
private _tempShrinkwrapFilename: string;
188188
private _tempShrinkwrapPreinstallFilename: string;
189-
private _rushUserFolder: string;
190-
private _versionIndependentRushUserFolder: string;
189+
private __rushUserFolder: string; // tslint:disable-line:variable-name
190+
private __rushNodeSpecificUserFolder: string; // tslint:disable-line:variable-name
191191
private _rushLinkJsonFilename: string;
192192
private _currentVariantJsonFilename: string;
193193
private _packageManagerToolVersion: string;
@@ -566,19 +566,21 @@ export class RushConfiguration {
566566
}
567567

568568
/**
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\`.
569+
* The absolute path to Rush's storage in the home directory for the current user, independent of node version.
570+
* On Windows, it would be something like `C:\Users\YourName\.rush\`.
571+
* @internal
571572
*/
572-
public get rushUserFolder(): string {
573-
return this._rushUserFolder;
573+
public get _rushUserFolder(): string {
574+
return this.__rushUserFolder;
574575
}
575576

576577
/**
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\`.
578+
* The absolute path to Rush's storage in the home directory for the current user and node version.
579+
* On Windows, it would be something like `C:\Users\YourName\.rush\node-v3.4.5`.
580+
* @internal
579581
*/
580-
public get versionIndependentRushUserFolder(): string {
581-
return this._versionIndependentRushUserFolder;
582+
public get _rushNodeSpecificUserFolder(): string {
583+
return this.__rushNodeSpecificUserFolder;
582584
}
583585

584586
/**
@@ -917,8 +919,8 @@ export class RushConfiguration {
917919
this._yarnCacheFolder = path.resolve(path.join(this._commonTempFolder, 'yarn-cache'));
918920

919921
this._changesFolder = path.join(this._commonFolder, RushConstants.changeFilesFolderName);
920-
this._versionIndependentRushUserFolder = path.join(Utilities.getHomeDirectory(), '.rush');
921-
this._rushUserFolder = path.join(this._versionIndependentRushUserFolder, `node-${process.version}`);
922+
this.__rushNodeSpecificUserFolder = path.join(Utilities.getHomeDirectory(), '.rush');
923+
this.__rushUserFolder = path.join(this.__rushNodeSpecificUserFolder, `node-${process.version}`);
922924

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

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

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -341,7 +341,7 @@ export class InstallManager {
341341
*/
342342
public ensureLocalPackageManager(): Promise<void> {
343343
// Example: "C:\Users\YourName\.rush"
344-
const rushUserFolder: string = this._rushConfiguration.rushUserFolder;
344+
const rushUserFolder: string = this._rushConfiguration._rushNodeSpecificUserFolder;
345345

346346
if (!FileSystem.exists(rushUserFolder)) {
347347
console.log('Creating ' + rushUserFolder);
@@ -925,7 +925,7 @@ export class InstallManager {
925925

926926
private _checkIfReleaseIsPublished(): Promise<boolean> {
927927
return Promise.resolve().then(() => {
928-
const lastCheckFile: string = path.join(this._rushConfiguration.rushUserFolder,
928+
const lastCheckFile: string = path.join(this._rushConfiguration._rushNodeSpecificUserFolder,
929929
'rush-' + Rush.version, 'last-check.flag');
930930

931931
if (FileSystem.exists(lastCheckFile)) {

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

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ export class PurgeManager {
2626
this._commonTempFolderRecycler = new AsyncRecycler(commonAsyncRecyclerPath);
2727

2828
const rushUserAsyncRecyclerPath: string = path.join(
29-
this._rushConfiguration.versionIndependentRushUserFolder,
29+
this._rushConfiguration._rushUserFolder,
3030
RushConstants.rushRecyclerFolderName
3131
);
3232
this._rushUserFolderRecycler = new AsyncRecycler(rushUserAsyncRecyclerPath);
@@ -64,9 +64,9 @@ export class PurgeManager {
6464
this.purgeNormal();
6565

6666
// Also delete everything under ~/.rush/node-v4.5.6/ except for the recycler folder itself
67-
console.log('Purging ' + this._rushConfiguration.rushUserFolder);
68-
this._rushUserFolderRecycler.moveAllItemsInFolder(this._rushConfiguration.rushUserFolder,
69-
this._getMembersToExclude(this._rushConfiguration.rushUserFolder));
67+
console.log('Purging ' + this._rushConfiguration._rushNodeSpecificUserFolder);
68+
this._rushUserFolderRecycler.moveAllItemsInFolder(this._rushConfiguration._rushNodeSpecificUserFolder,
69+
this._getMembersToExclude(this._rushConfiguration._rushNodeSpecificUserFolder));
7070
}
7171

7272
private _getMembersToExclude(folderToRecycle: string): string[] {

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

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -192,6 +192,10 @@ class Rush {
192192

193193
// @public
194194
class RushConfiguration {
195+
// @internal
196+
readonly _rushNodeSpecificUserFolder: string;
197+
// @internal
198+
readonly _rushUserFolder: string;
195199
readonly approvedPackagesPolicy: ApprovedPackagesPolicy;
196200
readonly changesFolder: string;
197201
// @deprecated
@@ -236,15 +240,13 @@ class RushConfiguration {
236240
readonly rushJsonFile: string;
237241
readonly rushJsonFolder: string;
238242
readonly rushLinkJsonFilename: string;
239-
readonly rushUserFolder: string;
240243
readonly shrinkwrapFilePhrase: string;
241244
// @beta
242245
readonly telemetryEnabled: boolean;
243246
readonly tempShrinkwrapFilename: string;
244247
readonly tempShrinkwrapPreinstallFilename: string;
245248
static tryFindRushJsonLocation(verbose?: boolean): string | undefined;
246249
tryGetProjectForPath(currentFolderPath: string): RushConfigurationProject | undefined;
247-
readonly versionIndependentRushUserFolder: string;
248250
// @beta (undocumented)
249251
readonly versionPolicyConfiguration: VersionPolicyConfiguration;
250252
readonly yarnCacheFolder: string;

0 commit comments

Comments
 (0)