Skip to content

Commit 88bb11f

Browse files
committed
Ensure the node version is a legal filename.
1 parent 992c519 commit 88bb11f

2 files changed

Lines changed: 10 additions & 2 deletions

File tree

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

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -920,7 +920,11 @@ export class RushConfiguration {
920920

921921
this._changesFolder = path.join(this._commonFolder, RushConstants.changeFilesFolderName);
922922
this.__rushNodeSpecificUserFolder = path.join(Utilities.getHomeDirectory(), '.rush');
923-
this.__rushUserFolder = path.join(this.__rushNodeSpecificUserFolder, `node-${process.version}`);
923+
924+
const normalizedNodeVersion: string = process.version.match(/^[a-z0-9\-\.]+$/i)
925+
? process.version
926+
: 'unknown-version';
927+
this.__rushUserFolder = path.join(this.__rushNodeSpecificUserFolder, `node-${normalizedNodeVersion}`);
924928

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

‎apps/rush/src/RushVersionSelector.ts‎

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,8 +25,12 @@ export class RushVersionSelector {
2525
public ensureRushVersionInstalled(version: string,
2626
configuration: MinimalRushConfiguration | undefined): Promise<void> {
2727

28+
const normalizedNodeVersion: string = process.version.match(/^[a-z0-9\-\.]+$/i)
29+
? process.version
30+
: 'unknown-version';
31+
2832
const isLegacyRushVersion: boolean = semver.lt(version, '4.0.0');
29-
const expectedRushPath: string = path.join(this._rushDirectory, `node-${process.version}`, `rush-${version}`);
33+
const expectedRushPath: string = path.join(this._rushDirectory, `node-${normalizedNodeVersion}`, `rush-${version}`);
3034

3135
const installMarker: _LastInstallFlag = new _LastInstallFlag(
3236
expectedRushPath,

0 commit comments

Comments
 (0)