From 5874dfd917d6716e2901c987253d876399571080 Mon Sep 17 00:00:00 2001 From: kingcody Date: Fri, 17 Jul 2015 01:16:31 -0400 Subject: [PATCH] feat(app): improve `Gruntfile.js` file globbing --- app/templates/Gruntfile.js | 116 ++++++++++--------------------------- 1 file changed, 31 insertions(+), 85 deletions(-) diff --git a/app/templates/Gruntfile.js b/app/templates/Gruntfile.js index 5799ac6f1..1062820f3 100644 --- a/app/templates/Gruntfile.js +++ b/app/templates/Gruntfile.js @@ -57,16 +57,13 @@ module.exports = function (grunt) { watch: { injectJS: { files: [ - '<%%= yeoman.client %>/{app,components}/**/*.js', - '!<%%= yeoman.client %>/{app,components}/**/*.spec.js', - '!<%%= yeoman.client %>/{app,components}/**/*.mock.js', - '!<%%= yeoman.client %>/app/app.js'], + '<%%= yeoman.client %>/{app,components}/**/!(*.spec|*.mock).js', + '!<%%= yeoman.client %>/app/app.js' + ], tasks: [<% if(filters.babel) { %>'newer:babel:client', <% } %>'injector:scripts'] }, injectCss: { - files: [ - '<%%= yeoman.client %>/{app,components}/**/*.css' - ], + files: ['<%%= yeoman.client %>/{app,components}/**/*.css'], tasks: ['injector:css'] }, mochaTest: { @@ -74,59 +71,46 @@ module.exports = function (grunt) { tasks: ['env:test', 'mochaTest'] }, jsTest: { - files: [ - '<%%= yeoman.client %>/{app,components}/**/*.spec.js', - '<%%= yeoman.client %>/{app,components}/**/*.mock.js' - ], + files: ['<%%= yeoman.client %>/{app,components}/**/*.{spec,mock}.js'], tasks: ['newer:jshint:all', 'karma'] },<% if (filters.stylus) { %> injectStylus: { - files: [ - '<%%= yeoman.client %>/{app,components}/**/*.styl'], + files: ['<%%= yeoman.client %>/{app,components}/**/*.styl'], tasks: ['injector:stylus'] }, stylus: { - files: [ - '<%%= yeoman.client %>/{app,components}/**/*.styl'], + files: ['<%%= yeoman.client %>/{app,components}/**/*.styl'], tasks: ['stylus', 'autoprefixer'] },<% } if (filters.sass) { %> injectSass: { - files: [ - '<%%= yeoman.client %>/{app,components}/**/*.{scss,sass}'], + files: ['<%%= yeoman.client %>/{app,components}/**/*.{scss,sass}'], tasks: ['injector:sass'] }, sass: { - files: [ - '<%%= yeoman.client %>/{app,components}/**/*.{scss,sass}'], + files: ['<%%= yeoman.client %>/{app,components}/**/*.{scss,sass}'], tasks: ['sass', 'autoprefixer'] },<% } if (filters.less) { %> injectLess: { - files: [ - '<%%= yeoman.client %>/{app,components}/**/*.less'], + files: ['<%%= yeoman.client %>/{app,components}/**/*.less'], tasks: ['injector:less'] }, less: { - files: [ - '<%%= yeoman.client %>/{app,components}/**/*.less'], + files: ['<%%= yeoman.client %>/{app,components}/**/*.less'], tasks: ['less', 'autoprefixer'] },<% } if (filters.jade) { %> jade: { files: [ '<%%= yeoman.client %>/{app,components}/*', - '<%%= yeoman.client %>/{app,components}/**/*.jade'], + '<%%= yeoman.client %>/{app,components}/**/*.jade' + ], tasks: ['jade'] },<% } if (filters.coffee) { %> coffee: { - files: [ - '<%%= yeoman.client %>/{app,components}/**/*.{coffee,litcoffee,coffee.md}', - '!<%%= yeoman.client %>/{app,components}/**/*.spec.{coffee,litcoffee,coffee.md}' - ], + files: ['<%%= yeoman.client %>/{app,components}/**/!(*.spec).{coffee,litcoffee,coffee.md}'], tasks: ['newer:coffee', 'injector:scripts'] }, coffeeTest: { - files: [ - '<%%= yeoman.client %>/{app,components}/**/*.spec.{coffee,litcoffee,coffee.md}' - ], + files: ['<%%= yeoman.client %>/{app,components}/**/*.spec.{coffee,litcoffee,coffee.md}'], tasks: ['karma'] },<% } %> gruntfile: { @@ -134,11 +118,8 @@ module.exports = function (grunt) { }, livereload: { files: [ - '{.tmp,<%%= yeoman.client %>}/{app,components}/**/*.css', - '{.tmp,<%%= yeoman.client %>}/{app,components}/**/*.html', - '{.tmp,<%%= yeoman.client %>}/{app,components}/**/*.js', - '!{.tmp,<%%= yeoman.client %>}/{app,components}/**/*.spec.js', - '!{.tmp,<%%= yeoman.client %>}/{app,components}/**/*.mock.js', + '{.tmp,<%%= yeoman.client %>}/{app,components}/**/*.{css,html}', + '{.tmp,<%%= yeoman.client %>}/{app,components}/**/!(*.spec|*.mock).js', '<%%= yeoman.client %>/assets/images/{,*//*}*.{png,jpg,jpeg,gif,webp,svg}' ], options: { @@ -146,9 +127,7 @@ module.exports = function (grunt) { } }, express: { - files: [ - 'server/**/*.{js,json}' - ], + files: ['server/**/*.{js,json}'], tasks: ['express:dev', 'wait'], options: { livereload: true, @@ -167,10 +146,7 @@ module.exports = function (grunt) { options: { jshintrc: 'server/.jshintrc' }, - src: [ - 'server/**/*.js', - '!server/**/*.{spec,integration}.js' - ] + src: ['server/**/!(*.spec|*.integration).js'] }, serverTest: { options: { @@ -178,16 +154,9 @@ module.exports = function (grunt) { }, src: ['server/**/*.{spec,integration}.js'] }, - all: [ - '<%%= yeoman.client %>/{app,components}/**/*.js', - '!<%%= yeoman.client %>/{app,components}/**/*.spec.js', - '!<%%= yeoman.client %>/{app,components}/**/*.mock.js' - ], + all: ['<%%= yeoman.client %>/{app,components}/**/!(*.spec|*.mock).js'], test: { - src: [ - '<%%= yeoman.client %>/{app,components}/**/*.spec.js', - '<%%= yeoman.client %>/{app,components}/**/*.mock.js' - ] + src: ['<%%= yeoman.client %>/{app,components}/**/*.{spec,mock}.js'] } }, @@ -198,7 +167,6 @@ module.exports = function (grunt) { main: { files: { src: [ - '<%%= yeoman.client %>/app/**/*.js', '<%%= yeoman.client %>/app/**/*.js', 'server/**/*.js' ] @@ -213,10 +181,7 @@ module.exports = function (grunt) { dot: true, src: [ '.tmp', - '<%%= yeoman.dist %>/*', - '!<%%= yeoman.dist %>/.git*', - '!<%%= yeoman.dist %>/.openshift', - '!<%%= yeoman.dist %>/Procfile' + '<%%= yeoman.dist %>/**/!(.git*|.openshift|Procfile)' ] }] }, @@ -285,8 +250,7 @@ module.exports = function (grunt) { filerev: { dist: { src: [ - '<%%= yeoman.dist %>/client/!(bower_components)/{,*/}*.js', - '<%%= yeoman.dist %>/client/!(bower_components)/{,*/}*.css', + '<%%= yeoman.dist %>/client/!(bower_components)/{,*/}*.{js,css}', '<%%= yeoman.dist %>/client/assets/images/{,*/}*.{png,jpg,jpeg,gif,webp,svg}', '<%%= yeoman.dist %>/client/assets/fonts/*' ] @@ -516,11 +480,7 @@ module.exports = function (grunt) { mocha_istanbul: { unit: { options: { - excludes: [ - '**/*.spec.js', - '**/*.mock.js', - '**/*.integration.js' - ], + excludes: ['**/*.{spec,mock,integration}.js'], reporter: 'spec', require: ['mocha.conf.js'], mask: '**/*.spec.js', @@ -530,11 +490,7 @@ module.exports = function (grunt) { }, integration: { options: { - excludes: [ - '**/*.spec.js', - '**/*.mock.js', - '**/*.integration.js' - ], + excludes: ['**/*.{spec,mock,integration}.js'], reporter: 'spec', require: ['mocha.conf.js'], mask: '**/*.integration.js', @@ -592,9 +548,7 @@ module.exports = function (grunt) { files: [{ expand: true, cwd: '<%%= yeoman.client %>', - src: [ - '{app,components}/**/*.jade' - ], + src: ['{app,components}/**/*.jade'], dest: '.tmp', ext: '.html' }] @@ -611,10 +565,7 @@ module.exports = function (grunt) { files: [{ expand: true, cwd: 'client', - src: [ - '{app,components}/**/*.coffee', - '!{app,components}/**/*.spec.coffee' - ], + src: ['{app,components}/**/!(*.spec).coffee'], dest: '.tmp', ext: '.js' }] @@ -630,10 +581,7 @@ module.exports = function (grunt) { files: [{ expand: true, cwd: '<%%= yeoman.client %>', - src: [ - '{app,components}/**/*.js', - '!{app,components}/**/*.spec.js' - ], + src: ['{app,components}/**/!(*.spec).js'], dest: '.tmp' }] } @@ -707,11 +655,9 @@ module.exports = function (grunt) { files: { '<%%= yeoman.client %>/index.html': [ [<% if(filters.babel) { %> - '.tmp/{app,components}/**/*.js',<% } else { %> - '{.tmp,<%%= yeoman.client %>}/{app,components}/**/*.js',<% } %> - '!{.tmp,<%%= yeoman.client %>}/app/app.js', - '!{.tmp,<%%= yeoman.client %>}/{app,components}/**/*.spec.js', - '!{.tmp,<%%= yeoman.client %>}/{app,components}/**/*.mock.js' + '.tmp/{app,components}/**/!(*.spec|*.mock).js',<% } else { %> + '{.tmp,<%%= yeoman.client %>}/{app,components}/**/!(*.spec|*.mock).js',<% } %> + '!{.tmp,<%%= yeoman.client %>}/app/app.js' ] ] }