Skip to content

Commit 9a91c64

Browse files
committed
rushx now sets the INIT_CWD appropriately when used inside a Rush repo
1 parent 2968525 commit 9a91c64

File tree

1 file changed

+12
-2
lines changed

1 file changed

+12
-2
lines changed

apps/rush-lib/src/cli/RushXCommandLine.ts

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@ import {
1212
} from '@microsoft/node-core-library';
1313
import { Utilities } from '../utilities/Utilities';
1414
import { ProjectCommandSet } from '../logic/ProjectCommandSet';
15+
import { RushConfiguration } from '../api/RushConfiguration';
1516

1617
export class RushXCommandLine {
1718
public static launchRushX(launcherVersion: string, isManaged: boolean): void {
@@ -66,13 +67,22 @@ export class RushXCommandLine {
6667
return;
6768
}
6869

70+
// Are we in a Rush repo?
71+
let rushConfiguration: RushConfiguration | undefined = undefined;
72+
if (RushConfiguration.tryFindRushJsonLocation(false)) {
73+
rushConfiguration = RushConfiguration.loadFromDefaultLocation();
74+
}
75+
6976
console.log('Executing: ' + JSON.stringify(scriptBody) + os.EOL);
7077

7178
const packageFolder: string = path.dirname(packageJsonFilePath);
7279

73-
const exitCode: number = Utilities.executeLifecycleCommand(scriptBody, {
80+
const exitCode: number = Utilities.executeLifecycleCommand(scriptBody,
81+
{
7482
workingDirectory: packageFolder,
75-
initCwd: packageFolder,
83+
// If there is a rush.json then use its .npmrc from the temp folder.
84+
// Otherwise look for npmrc in the project folder.
85+
initCwd: rushConfiguration ? rushConfiguration.commonTempFolder : packageFolder,
7686
handleOutput: false
7787
}
7888
);

0 commit comments

Comments
 (0)