11'use strict' ;
22
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' ) ;
3+ var gulp = require ( 'gulp' ) ,
4+ path = require ( 'path' ) ,
5+ slash = require ( 'gulp-slash' ) ,
6+ bowerDir = require ( 'bower-directory' ) ;
97
10- var bowerFiles = require ( '../inject/bower-files' ) ;
8+ var bowerFiles = require ( '../inject/bower-files' ) ,
9+ libGlobber = require ( './lib-globber' ) ;
1110
1211var NODE = 'node_modules' ,
1312 BOWER = path . relative ( process . cwd ( ) , bowerDir . sync ( ) ) ,
@@ -17,29 +16,9 @@ var NODE = 'node_modules',
1716 TEST = 'app-test' ,
1817 RELEASE_BUNDLE = 'app-release' ,
1918 RELEASE_VENDOR = 'app-release/vendor' ,
20- ROUTES = reduce ( [ '' , BOWER , BUILD ] , mapRoutes , { } ) ;
19+ ROUTES = [ '' , BOWER , BUILD ] . reduce ( mapRoutes , { } ) ;
2120
22- /**
23- * Create a glob generator that only includes files from the local library, unless additional paths are given.
24- * Additional paths must be of the form <code>NODE</code>, <code>BOWER</code>, <code>APP</code>, or
25- * <code>GENERATED</code>.
26- * @param {...string } [additional] Any number of non-library directories to include
27- * @return {function({Array}) } A multi-element glob pattern
28- */
29- function getLocalLibGlob ( ) {
30- var additional = flatten ( Array . prototype . slice . call ( arguments ) ) ;
31- var excludes = [ NODE , BOWER , APP , GENERATED ]
32- . filter ( function convertAdditionalToExclude ( element ) {
33- return ( additional . indexOf ( element ) < 0 ) ;
34- } )
35- . map ( function excludeDirectory ( exclude ) {
36- return '!' + exclude + '/**' ;
37- } ) ;
38- return function ( ) {
39- return flatten ( Array . prototype . slice . call ( arguments ) )
40- . concat ( excludes ) ; // important - excludes must come after includes
41- } ;
42- }
21+ var getLocalLibGlob = libGlobber ( NODE , BOWER , APP , GENERATED ) ;
4322
4423function mapRoutes ( result , path ) {
4524 result [ '/' + slash ( path ) ] = path ; // result['/<path>'] = <path>
@@ -51,11 +30,11 @@ function jsApp(opts) {
5130}
5231
5332function jsLib ( opts ) {
54- return gulp . src ( getLocalLibGlob ( ) ( '**/*.js' , '!*.js' , '!* */*.spec.js') , opts ) ;
33+ return gulp . src ( getLocalLibGlob ( ) ( '**/*.js' , '!**/*.spec.js' ) , opts ) ;
5534}
5635
5736function jsSpec ( opts ) {
58- return gulp . src ( getLocalLibGlob ( ) ( '**/*.spec.js' , '!*.spec.js' ) , opts ) ;
37+ return gulp . src ( getLocalLibGlob ( ) ( '**/*.spec.js' ) , opts ) ;
5938}
6039
6140function scssApp ( opts ) {
0 commit comments