Skip to content

Commit 77daa17

Browse files
Copiloticlanton
andcommitted
Use consistent cwd from RushCommandLineParser for path resolution
Co-authored-by: iclanton <5010588+iclanton@users.noreply.github.com>
1 parent 4967774 commit 77daa17

6 files changed

Lines changed: 22 additions & 6 deletions

File tree

libraries/rush-lib/src/cli/RushCommandLineParser.ts

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -88,6 +88,13 @@ export class RushCommandLineParser extends CommandLineParser {
8888
private readonly _terminal: Terminal;
8989
private readonly _autocreateBuildCommand: boolean;
9090

91+
/**
92+
* The current working directory that was used to find the Rush configuration.
93+
*/
94+
public get cwd(): string {
95+
return this._rushOptions.cwd;
96+
}
97+
9198
public constructor(options?: Partial<IRushCommandLineParserOptions>) {
9299
super({
93100
toolFilename: 'rush',

libraries/rush-lib/src/cli/actions/InstallAction.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,8 @@ export class InstallAction extends BaseInstallAction {
4141
// Disable filtering because rush-project.json is riggable and therefore may not be available
4242
enableFiltering: false
4343
},
44-
includeSubspaceSelector: true
44+
includeSubspaceSelector: true,
45+
cwd: this.parser.cwd
4546
});
4647

4748
this._checkOnlyParameter = this.defineFlagParameter({

libraries/rush-lib/src/cli/actions/ListAction.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -116,7 +116,8 @@ export class ListAction extends BaseRushAction {
116116
// Disable filtering because rush-project.json is riggable and therefore may not be available
117117
enableFiltering: false
118118
},
119-
includeSubspaceSelector: false
119+
includeSubspaceSelector: false,
120+
cwd: this.parser.cwd
120121
});
121122
}
122123

libraries/rush-lib/src/cli/actions/UpdateAction.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,8 @@ export class UpdateAction extends BaseInstallAction {
4545
// Disable filtering because rush-project.json is riggable and therefore may not be available
4646
enableFiltering: false
4747
},
48-
includeSubspaceSelector: true
48+
includeSubspaceSelector: true,
49+
cwd: this.parser.cwd
4950
});
5051
}
5152

libraries/rush-lib/src/cli/parsing/SelectionParameterSet.ts

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,11 @@ export const SUBSPACE_LONG_ARG_NAME: '--subspace' = '--subspace';
3030
interface ISelectionParameterSetOptions {
3131
gitOptions: IGitSelectorParserOptions;
3232
includeSubspaceSelector: boolean;
33+
/**
34+
* The working directory used to resolve relative paths.
35+
* This should be the same directory that was used to find the Rush configuration.
36+
*/
37+
cwd: string;
3338
}
3439

3540
/**
@@ -59,7 +64,7 @@ export class SelectionParameterSet {
5964
action: CommandLineParameterProvider,
6065
options: ISelectionParameterSetOptions
6166
) {
62-
const { gitOptions, includeSubspaceSelector } = options;
67+
const { gitOptions, includeSubspaceSelector, cwd } = options;
6368
this._rushConfiguration = rushConfiguration;
6469

6570
const selectorParsers: Map<string, ISelectorParser<RushConfigurationProject>> = new Map<
@@ -73,7 +78,7 @@ export class SelectionParameterSet {
7378
selectorParsers.set('tag', new TagProjectSelectorParser(rushConfiguration));
7479
selectorParsers.set('version-policy', new VersionPolicyProjectSelectorParser(rushConfiguration));
7580
selectorParsers.set('subspace', new SubspaceSelectorParser(rushConfiguration));
76-
selectorParsers.set('path', new PathProjectSelectorParser(rushConfiguration, process.cwd()));
81+
selectorParsers.set('path', new PathProjectSelectorParser(rushConfiguration, cwd));
7782

7883
this._selectorParserByScope = selectorParsers;
7984

libraries/rush-lib/src/cli/scriptActions/PhasedScriptAction.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -236,7 +236,8 @@ export class PhasedScriptAction extends BaseScriptAction<IPhasedCommandConfig> i
236236
// Enable filtering to reduce evaluation cost
237237
enableFiltering: true
238238
},
239-
includeSubspaceSelector: false
239+
includeSubspaceSelector: false,
240+
cwd: this.parser.cwd
240241
});
241242

242243
this._verboseParameter = this.defineFlagParameter({

0 commit comments

Comments
 (0)