@@ -413,32 +413,40 @@ function create(params, cb) {
413413 }
414414 } ) ;
415415
416+ //exclude git based files in archive.glob
417+ var ignoreGlob = [ '**/.git/**' , '**/.git' , '**/.gitignore' ]
418+
416419 // exclude user supplied --ignoreFiles as well: folders or files
417420 if ( params . ignoreFiles ) {
418421 if ( typeof params . ignoreFiles === 'string' ) {
419422 var ignoreFilesArray = params . ignoreFiles . split ( ',' )
420- ignoreFilesArray . forEach ( element => {
421- fs . lstat ( params . workspace + '/' + element , ( err , stats ) => {
423+ ignoreFilesArray . forEach ( function ( element ) {
424+ fs . lstat ( params . workspace + '/' + element . trim ( ) , ( err , stats ) => {
422425 if ( err ) {
423- var err = new Error ( 'Error: ignoreFiles argument not found: aborting ' ) ;
426+ var err = new Error ( 'Error: ignoreFiles argument not found' ) ;
424427 return ifCliPrintErrorOnly ( err ) ;
425428 }
429+ if ( stats . isDirectory ( ) ) {
430+ element = '**/' + element + '/**'
431+ }
432+ console . log ( element )
426433 } )
427- element = '**/' + element
428- } ) ;
429- } else {
430- var err = new Error ( 'Error: ignoreFiles argument should be folder or file in string format' ) ;
431- return ifCliPrintErrorOnly ( err ) ;
434+ } )
435+ console . log ( ignoreFilesArray )
436+ ignoreGlob = ignoreGlob . concat ( ignoreFilesArray )
437+ } else {
438+ var err = new Error ( 'Error: ignoreFiles argument should be folder or file name in string format' ) ;
439+ return ifCliPrintErrorOnly ( err ) ;
440+ }
432441 }
433- }
434-
435-
442+ console . log ( ignoreGlob )
443+
436444 archive . pipe ( output ) ;
437445 if ( stat . isDirectory ( ) ) {
438446 // include . prefixed folders and files but exclude .git and .gitignore folders and files
439447 archive . glob ( '**/*' , {
440448 cwd : params . workspace ,
441- ignore : [ '**/.git/**' , '**/.git' , '**/.gitignore' ] . concat ( ignoreFilesArray ) ,
449+ ignore : ignoreGlob ,
442450 dot : true ,
443451 } , false ) ;
444452 } else {
0 commit comments