Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(@angular-devkit/architect): improve error message when configuration is missing #29747

Merged
merged 1 commit into from
Mar 4, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
20 changes: 7 additions & 13 deletions tests/legacy-cli/e2e/tests/commands/unknown-configuration.ts
Original file line number Diff line number Diff line change
@@ -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/,
);
}