You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
The information pertaining to option config and argument config needs to be changed in both Interacting with the user and in the API.
The type property of both configs can be a custom function with the argument config also accepting an actual array. It is much clearer to specify in this manner compared to how it is currently. For instance, for argument config it states 'String, Number, Array (can also be a custom function receiving the raw string value and parsing it)' this would be better served with Array, function(arg):actual
These custom functions do have different input types though as well as different defaults. The option config will always have the function called and so can be any type given that the default will be passed when the option is missing otherwise will be the provided value. The argument config will only be passed the raw string argument.
'use strict';/* eslint no-unused-vars: ["error", { "varsIgnorePattern": "[iI]gnored" }] *//* eslint max-params: ["error", 5] */varGenerator=require('yeoman-generator');varhelpers=require('yeoman-test');varboolValue=true;vardefaultOptionValue={someProp: 'someValue'};varboolTypeFn=jest.fn(()=>{});vardefaultFn=jest.fn(()=>{});vartestGenerator=classextendsGenerator{// Supposedly this is unnecessary http://eslint.org/docs/rules/no-useless-constructor// http://eslint.org/docs/user-guide/configuringconstructor(args,opts){super(args,opts);this.option('boolOption',{type: boolTypeFn});this.option('defaultObjectOption',{default: defaultOptionValue,type: defaultFn});}initializing(){}};describe('documentation is incorrect on options config type property',()=>{beforeAll(()=>{returnhelpers.run(testGenerator).withOptions({boolOption: boolValue}).withArguments([]);});it('receives the option value',()=>{expect(boolTypeFn).toHaveBeenCalledWith(true);});it('receives the default value for an option that has not been provided',()=>{expect(defaultFn).toHaveBeenCalledWith(defaultOptionValue);});});
The text was updated successfully, but these errors were encountered:
tonyhallett
changed the title
Incorrect documentation
Incorrect documentation: object config
Apr 16, 2017
The information pertaining to option config and argument config needs to be changed in both Interacting with the user and in the API.
The type property of both configs can be a custom function with the argument config also accepting an actual array. It is much clearer to specify in this manner compared to how it is currently. For instance, for argument config it states 'String, Number, Array (can also be a custom function receiving the raw string value and parsing it)' this would be better served with Array, function(arg):actual
These custom functions do have different input types though as well as different defaults. The option config will always have the function called and so can be any type given that the default will be passed when the option is missing otherwise will be the provided value. The argument config will only be passed the raw string argument.
The text was updated successfully, but these errors were encountered: