diff --git a/packages/angular_devkit/architect/node/node-modules-architect-host.ts b/packages/angular_devkit/architect/node/node-modules-architect-host.ts index c70d303f2dfc..f1cd327136e2 100644 --- a/packages/angular_devkit/architect/node/node-modules-architect-host.ts +++ b/packages/angular_devkit/architect/node/node-modules-architect-host.ts @@ -104,8 +104,11 @@ export class WorkspaceNodeModulesArchitectHost implements ArchitectHost { - if (!/^[^:]+:[^:]+$/.test(name)) { + // The below will match 'project:target:configuration' + if (!/^[^:]+:[^:]+(:[^:]+)?$/.test(name)) { throw new Error('Invalid builder name: ' + JSON.stringify(name)); } diff --git a/packages/angular_devkit/architect/src/index_spec.ts b/packages/angular_devkit/architect/src/index_spec.ts index 24a44e487d49..cac45b39de5e 100644 --- a/packages/angular_devkit/architect/src/index_spec.ts +++ b/packages/angular_devkit/architect/src/index_spec.ts @@ -106,6 +106,15 @@ describe('architect', () => { await run.stop(); }); + it(`errors when target configuration doesn't exists`, async () => { + try { + await architect.scheduleBuilder('test:test:invalid', {}); + throw new Error('should have thrown'); + } catch (err) { + expect(err.message).toContain('Job name "test:test:invalid" does not exist.'); + } + }); + it('errors when builder cannot be resolved', async () => { try { await architect.scheduleBuilder('non:existent', {}); diff --git a/tests/legacy-cli/e2e/tests/commands/unknown-configuration.ts b/tests/legacy-cli/e2e/tests/commands/unknown-configuration.ts new file mode 100644 index 000000000000..98257ee86e70 --- /dev/null +++ b/tests/legacy-cli/e2e/tests/commands/unknown-configuration.ts @@ -0,0 +1,12 @@ +import { ng } from "../../utils/process"; + +export default async function () { + try { + await ng('build', '--configuration', 'invalid'); + throw new Error('should have failed.'); + } catch (error) { + if (!error.message.includes(`Configuration 'invalid' is not set in the workspace`)) { + throw error; + } + } +};