File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -32,6 +32,8 @@ function option({
3232 : defaultValue ;
3333 } else if ( ! isDeprecated ) {
3434 throw new MissingOptionError ( locator . name ) ;
35+ } else {
36+ isSetByUser = false ;
3537 }
3638
3739 if ( isSetByUser && isDeprecated ) {
Original file line number Diff line number Diff line change 1+ const sinon = require ( 'sinon' ) ;
12const { option} = require ( '../lib/core' ) ;
23const { MissingOptionError} = require ( '../lib/errors' ) ;
34
45describe ( 'option' , ( ) => {
6+ let consoleWarnStub ;
7+
8+ beforeEach ( ( ) => {
9+ consoleWarnStub = sinon . stub ( console , 'warn' ) ;
10+ } ) ;
11+
12+ afterEach ( ( ) => {
13+ consoleWarnStub . restore ( ) ;
14+ } ) ;
15+
516 const LAZY_CONFIG = {
617 root : { defaultKey : 'defaultValue' }
718 } ;
@@ -155,6 +166,18 @@ describe('option', () => {
155166 const parser = option ( { isDeprecated : true } ) ;
156167 assert . doesNotThrow ( ( ) => parser ( { } , LAZY_CONFIG ) , MissingOptionError ) ;
157168 } ) ;
169+
170+ it ( 'should not log warning on deprecated option without any value' , ( ) => {
171+ option ( { isDeprecated : true } ) ( { } , LAZY_CONFIG ) ;
172+
173+ assert . notCalled ( consoleWarnStub ) ;
174+ } ) ;
175+ } ) ;
176+
177+ it ( 'should log warning on deprecated option if option is set' , ( ) => {
178+ option ( { isDeprecated : true } ) ( { envVar : 'foo' } , LAZY_CONFIG ) ;
179+
180+ assert . calledWith ( consoleWarnStub , sinon . match ( 'option is deprecated' ) ) ;
158181 } ) ;
159182
160183 function testAfterParseCallback ( name ) {
You can’t perform that action at this time.
0 commit comments