Skip to content

Commit

Permalink
fix(@angular-devkit/architect): improve error message when configurat…
Browse files Browse the repository at this point in the history
…ion is missing

This commit makes the error message more actionable.

Closes #29742

(cherry picked from commit 6f0e90e)
  • Loading branch information
alan-agius4 committed Mar 4, 2025
1 parent c073309 commit 3ebd7ca
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 14 deletions.
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/,
);
}

0 comments on commit 3ebd7ca

Please sign in to comment.