11'use strict' ;
22
3- var gulp = require ( 'gulp' ) ,
4- path = require ( 'path' ) ,
5- reduce = require ( 'lodash.reduce' ) ,
6- slash = require ( 'gulp-slash' ) ,
7- bowerDir = require ( 'bower-directory' ) ;
3+ var gulp = require ( 'gulp' ) ,
4+ path = require ( 'path' ) ,
5+ flatten = require ( 'lodash.flatten' ) ,
6+ reduce = require ( 'lodash.reduce' ) ,
7+ slash = require ( 'gulp-slash' ) ,
8+ bowerDir = require ( 'bower-directory' ) ;
89
910var bowerFiles = require ( '../inject/bower-files' ) ;
1011
1112var NODE = 'node_modules' ,
1213 BOWER = path . relative ( process . cwd ( ) , bowerDir . sync ( ) ) ,
1314 APP = 'app' ,
15+ GENERATED = 'app-*' ,
1416 BUILD = 'app-build' ,
1517 TEST = 'app-test' ,
1618 RELEASE_BUNDLE = 'app-release' ,
1719 RELEASE_VENDOR = 'app-release/vendor' ,
1820 ROUTES = reduce ( [ '' , BOWER , BUILD ] , mapRoutes , { } ) ;
1921
2022/**
21- * Create a glob with the given pattern elements, and additional directory
22- * @param {Array|string } pattern One or more glob pattern entries to be included as-in
23- * @param {Array|string } [additional] Any number of non-library directories to include
24- * @return {Array } A multi-element glob pattern
23+ * Create a glob generator that features the given additional directories
24+ * @param {...string } [additional] Any number of non-library directories to include
25+ * @return {function({Array}) } A multi-element glob pattern
2526 */
26- function getGlob ( pattern , additional ) {
27- var patternArray = ( typeof pattern === 'string' ) ? [ pattern ] : pattern || [ ] ;
28- var additionalArray = ( typeof additional === 'string' ) ? [ additional ] : additional || [ ] ;
29- return patternArray . concat ( [ NODE , BOWER , APP , BUILD , TEST , RELEASE_BUNDLE , RELEASE_VENDOR ]
27+ function getGlob ( ) {
28+ var additional = flatten ( Array . prototype . slice . call ( arguments ) ) ;
29+ var excludes = [ NODE , BOWER , APP , GENERATED ]
3030 . filter ( function convertAdditionalToExclude ( element ) {
31- return ( additionalArray . indexOf ( element ) < 0 ) ;
31+ return ( additional . indexOf ( element ) < 0 ) ;
3232 } )
33- . map ( function excludeDir ( exclude ) {
33+ . map ( function excludeDirectory ( exclude ) {
3434 return '!' + exclude + '/**' ;
35- } ) ) ;
35+ } ) ;
36+ return function ( ) {
37+ return flatten ( Array . prototype . slice . call ( arguments ) )
38+ . concat ( excludes ) ; // important - excludes must come after includes
39+ }
3640}
3741
3842function mapRoutes ( result , path ) {
@@ -45,11 +49,11 @@ function jsApp(opts) {
4549}
4650
4751function jsLib ( opts ) {
48- return gulp . src ( getGlob ( [ '**/*.js' , '!*.js' , '!**/*.spec.js' ] ) , opts ) ;
52+ return gulp . src ( getGlob ( ) ( '**/*.js' , '!*.js' , '!**/*.spec.js' ) , opts ) ;
4953}
5054
5155function jsSpec ( opts ) {
52- return gulp . src ( getGlob ( [ '**/*.spec.js' , '!*.spec.js' ] ) , opts ) ;
56+ return gulp . src ( getGlob ( ) ( '**/*.spec.js' , '!*.spec.js' ) , opts ) ;
5357}
5458
5559function scssApp ( opts ) {
@@ -63,7 +67,7 @@ function htmlApp(opts) {
6367function testDependencies ( opts ) {
6468 return bowerFiles ( 80 )
6569 . src ( 'js' , opts ) ;
66- } ;
70+ }
6771
6872module . exports = {
6973 NODE : NODE ,
0 commit comments