mirror of
https://github.com/angular/angular-cli.git
synced 2025-05-15 10:11:50 +08:00
fix(@angular-devkit/architect): improve error message when configuration is missing
This commit makes the error message more actionable. Closes #29742
This commit is contained in:
parent
280693231e
commit
6f0e90e215
@ -90,7 +90,9 @@ export class WorkspaceNodeModulesArchitectHost implements ArchitectHost<NodeModu
|
||||
}
|
||||
|
||||
if (!targetDefinition.configurations?.[configuration]) {
|
||||
throw new Error(`Configuration '${configuration}' is not set in the workspace.`);
|
||||
throw new Error(
|
||||
`Configuration '${configuration}' for target '${target}' in project '${project}' is not set in the workspace.`,
|
||||
);
|
||||
}
|
||||
|
||||
return (targetDefinition.configurations?.[configuration] ?? {}) as json.JsonObject;
|
||||
|
@ -1,17 +1,11 @@
|
||||
import assert from 'node:assert';
|
||||
import { ng } from '../../utils/process';
|
||||
import { expectToFail } from '../../utils/utils';
|
||||
|
||||
export default async function () {
|
||||
try {
|
||||
await ng('build', '--configuration', 'invalid');
|
||||
throw new Error('should have failed.');
|
||||
} catch (error) {
|
||||
if (
|
||||
!(
|
||||
error instanceof Error &&
|
||||
error.message.includes(`Configuration 'invalid' is not set in the workspace`)
|
||||
)
|
||||
) {
|
||||
throw error;
|
||||
}
|
||||
}
|
||||
const error = await expectToFail(() => ng('build', '--configuration', 'invalid'));
|
||||
assert.match(
|
||||
error.message,
|
||||
/Configuration 'invalid' for target 'build' in project 'test-project' is not set in the workspace/,
|
||||
);
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user