Skip to content

fix(@angular/cli): honor builder schema additional properties option #14365

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

Merged
merged 1 commit into from
May 9, 2019
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
5 changes: 4 additions & 1 deletion packages/angular/cli/models/architect-command.ts
Original file line number Diff line number Diff line change
Expand Up @@ -239,7 +239,10 @@ export abstract class ArchitectCommand<
);
const overrides = parseArguments(targetOptions, targetOptionArray, this.logger);

if (overrides['--']) {
const allowAdditionalProperties = typeof builderDesc.optionSchema === 'object'
&& builderDesc.optionSchema.additionalProperties;

if (overrides['--'] && !allowAdditionalProperties) {
(overrides['--'] || []).forEach(additional => {
this.logger.fatal(`Unknown option: '${additional.split(/=/)[0]}'`);
});
Expand Down
28 changes: 28 additions & 0 deletions tests/legacy-cli/e2e/tests/commands/additional-properties.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
import { createDir, rimraf, writeMultipleFiles } from '../../utils/fs';
import { execAndWaitForOutputToMatch } from '../../utils/process';
import { updateJsonFile } from '../../utils/project';

export default async function() {
await createDir('example-builder');
await writeMultipleFiles({
'example-builder/package.json': '{ "builders": "./builders.json" }',
'example-builder/schema.json': '{ "$schema": "http://json-schema.org/draft-07/schema", "type": "object", "additionalProperties": true }',
'example-builder/builders.json': '{ "$schema": "@angular-devkit/architect/src/builders-schema.json", "builders": { "example": { "implementation": "./example", "schema": "./schema.json" } } }',
'example-builder/example.js': 'module.exports.default = require("@angular-devkit/architect").createBuilder((options) => { console.log(options); return { success: true }; });',
});
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nice.


await updateJsonFile('angular.json', json => {
const appArchitect = json.projects['test-project'].architect;
appArchitect.example = {
builder: './example-builder:example',
};
});

await execAndWaitForOutputToMatch(
'ng',
['run', 'test-project:example', '--additional', 'property'],
/'{ '--': \[ '--additional', 'property' \] }'/,
);

await rimraf('example-builder');
}