8000 Show an error message if useWorkspaces=false when trying to use subsp… · nirshar/rushstack@bb95399 · GitHub
[go: up one dir, main page]

Skip to content

Commit bb95399

Browse files
committed
Show an error message if useWorkspaces=false when trying to use subspaces
1 parent 6266d51 commit bb95399

File tree

2 files changed

+15
-4
lines changed

2 files changed

+15
-4
lines changed

libraries/rush-lib/assets/rush-init/rush.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -339,7 +339,7 @@
339339
* and "nonbrowser-approved-packages.json" files. The value must be one of the
340340
* strings from the "reviewCategories" defined above.
341341
*/
342-
/*[LINE "HYPOTHETICAL"]*/ "reviewCategory": "production",
342+
"reviewCategory": "production",
343343

344344
/**
345345
* A list of Rush project names that are to be installed from NPM

libraries/rush-lib/src/api/Subspace.ts

Lines changed: 14 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -67,18 +67,23 @@ export class Subspace {
6767
*/
6868
public getPnpmOptions(): PnpmOptionsConfiguration | undefined {
6969
if (!this._cachedPnpmOptionsInitialized) {
70+
// Calculate these outside the try/catch block since their error messages shouldn't be annotated:
71+
const subspaceConfigFolder: string = this.getSubspaceConfigFolder();
72+
const subspaceTempFolder: string = this.getSubspaceTempFolder();
7073
try {
7174
this._cachedPnpmOptions = PnpmOptionsConfiguration.loadFromJsonFileOrThrow(
72-
`${this.getSubspaceConfigFolder()}/${RushConstants.pnpmConfigFilename}`,
73-
this.getSubspaceTempFolder()
75+
`${subspaceConfigFolder}/${RushConstants.pnpmConfigFilename}`,
76+
subspaceTempFolder
7477
);
7578
this._cachedPnpmOptionsInitialized = true;
7679
} catch (e) {
7780
if (FileSystem.isNotExistError(e as Error)) {
7881
this._cachedPnpmOptions = undefined;
7982
this._cachedPnpmOptionsInitialized = true;
8083
} else {
81-
throw new Error(`The subspace has an invalid pnpm-config.json file: ${this.subspaceName}`);
84+
throw new Error(
85+
`The subspace "${this.subspaceName}" has an invalid pnpm-config.json file:\n` + e.message
86+
);
8287
}
8388
}
8489
}
@@ -91,6 +96,12 @@ export class Subspace {
9196
let subspaceConfigFolder: string;
9297

9398
if (rushConfiguration.subspacesFeatureEnabled) {
99+
if (!rushConfiguration.pnpmOptions.useWorkspaces) {
100+
throw new Error(
101+
`The Rush subspaces feature is enabled. You must set useWorkspaces=true in pnpm-config.json.`
102+
);
103+
}
104+
94105
// If this subspace doesn't have a configuration folder, check if it is in the project folder itself
95106
// if the splitWorkspaceCompatibility option is enabled in the subspace configuration
96107

0 commit comments

Comments
 (0)
0