refactor: add allowAdditionalArgs to be able to bypass extra params validations (#13556)

This commit is contained in:
Alan Agius 2019-02-06 06:13:45 +01:00 committed by vikerman
parent 95dee5a649
commit 71c6cc506e
2 changed files with 3 additions and 1 deletions

View File

@ -25,6 +25,7 @@ const npa = require('npm-package-arg');
export class AddCommand extends SchematicCommand<AddCommandSchema> {
readonly allowPrivateSchematics = true;
readonly allowAdditionalArgs = true;
readonly packageManager = getPackageManager(this.workspace.root);
async run(options: AddCommandSchema & Arguments) {

View File

@ -77,6 +77,7 @@ export abstract class SchematicCommand<
T extends (BaseSchematicSchema & BaseCommandOptions),
> extends Command<T> {
readonly allowPrivateSchematics: boolean = false;
readonly allowAdditionalArgs: boolean = false;
private _host = new NodeJsSyncHost();
private _workspace: experimental.workspace.Workspace;
private readonly _engine: Engine<FileSystemCollectionDesc, FileSystemSchematicDesc>;
@ -438,7 +439,7 @@ export abstract class SchematicCommand<
}
// ng-add is special because we don't know all possible options at this point
if (args['--'] && schematicName !== 'ng-add') {
if (args['--'] && !this.allowAdditionalArgs) {
args['--'].forEach(additional => {
this.logger.fatal(`Unknown option: '${additional.split(/=/)[0]}'`);
});