Skip to content

Commit 81a399e

Browse files
committed
fix --ignore-packages empty
1 parent fb579fa commit 81a399e

2 files changed

Lines changed: 22 additions & 4 deletions

File tree

src/lib/options/checkoutdated.js

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -192,9 +192,10 @@ function toArgs( grunt, task, options ) {
192192
args.push( _STRINGS.OPTIONS_IGNORE_DEV_DEPENDENCIES );
193193
}
194194
if (( options.checkoutdated.ignore.packages ) &&
195-
( Array.isArray( options.checkoutdated.ignore.packages ))) {
196-
const s = options.checkoutdated.ignore.packages.join( "," );
197-
args.push( _STRINGS.OPTIONS_IGNORE_PACKAGES, s );
195+
(( Array.isArray( options.checkoutdated.ignore.packages ) &&
196+
( options.checkoutdated.ignore.packages.length > 0 )))) {
197+
const s = options.checkoutdated.ignore.packages.join( "," );
198+
args.push( _STRINGS.OPTIONS_IGNORE_PACKAGES, s );
198199
}
199200
}
200201

src/test/any/02.00.options.checkoutdated.spec.js

Lines changed: 18 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -210,17 +210,33 @@ const path = require( "path" );
210210
.catch(( error ) => { done( error ); })
211211
}).not.to.throwException();
212212
});
213+
it( "should be callable with parameters 'grunt' {grunt}, 'task' {task}, 'options' {object} and resolve (options.checkoutdated.ignore.packages = [ ])", ( done ) => {
214+
const arg = [ ];
215+
const options = chkoutdt.getTaskOptions( env.task );
216+
options.checkoutdated.ignore.packages = arg;
217+
expect(() => { chkoutdt.toArgs( env.grunt, env.task, options )
218+
.then(( value ) => {
219+
// console.log( value );
220+
expect( value ).to.be.an( "object" );
221+
expect( value.opts.checkoutdated.ignore.packages === arg ).to.be.ok();
222+
expect( value.args.includes( "--ignore-packages" )).not.to.be.ok();
223+
done();
224+
})
225+
.catch(( error ) => { done( error ); })
226+
}).not.to.throwException();
227+
});
213228
it( "should be callable with parameters 'grunt' {grunt}, 'task' {task}, 'options' {object} and resolve (options.checkoutdated.ignore.packages = [ 'some-package' ])", ( done ) => {
214229
const pkg = "some-package";
215230
const arg = [ pkg ];
216231
const options = chkoutdt.getTaskOptions( env.task );
217232
options.checkoutdated.ignore.packages = arg;
218233
expect(() => { chkoutdt.toArgs( env.grunt, env.task, options )
219234
.then(( value ) => {
220-
// console.log( value );
235+
console.log( value );
221236
expect( value ).to.be.an( "object" );
222237
expect( value.opts.checkoutdated.ignore.packages === arg ).to.be.ok();
223238
expect( value.args.includes( pkg )).to.be.ok();
239+
expect( value.args.includes( "--ignore-packages" )).to.be.ok();
224240
done();
225241
})
226242
.catch(( error ) => { done( error ); })
@@ -235,6 +251,7 @@ const path = require( "path" );
235251
// console.log( value );
236252
expect( value ).to.be.an( "object" );
237253
expect( value.opts.checkoutdated.ignore.packages === arg ).to.be.ok();
254+
expect( value.args.includes( "--ignore-packages" )).not.to.be.ok();
238255
done();
239256
})
240257
.catch(( error ) => { done( error ); })

0 commit comments

Comments
 (0)