Skip to content

Commit 1249392

Browse files
committed
Merge pull request angular-fullstack#1076 from kingcody/feature/improved-globs
feat(app): improve `Gruntfile.js` file globbing
2 parents 40800f1 + 5874dfd commit 1249392

File tree

1 file changed

+31
-85
lines changed

1 file changed

+31
-85
lines changed

app/templates/Gruntfile.js

+31-85
Original file line numberDiff line numberDiff line change
@@ -57,98 +57,77 @@ module.exports = function (grunt) {
5757
watch: {
5858
injectJS: {
5959
files: [
60-
'<%%= yeoman.client %>/{app,components}/**/*.js',
61-
'!<%%= yeoman.client %>/{app,components}/**/*.spec.js',
62-
'!<%%= yeoman.client %>/{app,components}/**/*.mock.js',
63-
'!<%%= yeoman.client %>/app/app.js'],
60+
'<%%= yeoman.client %>/{app,components}/**/!(*.spec|*.mock).js',
61+
'!<%%= yeoman.client %>/app/app.js'
62+
],
6463
tasks: [<% if(filters.babel) { %>'newer:babel:client', <% } %>'injector:scripts']
6564
},
6665
injectCss: {
67-
files: [
68-
'<%%= yeoman.client %>/{app,components}/**/*.css'
69-
],
66+
files: ['<%%= yeoman.client %>/{app,components}/**/*.css'],
7067
tasks: ['injector:css']
7168
},
7269
mochaTest: {
7370
files: ['server/**/*.spec.js'],
7471
tasks: ['env:test', 'mochaTest']
7572
},
7673
jsTest: {
77-
files: [
78-
'<%%= yeoman.client %>/{app,components}/**/*.spec.js',
79-
'<%%= yeoman.client %>/{app,components}/**/*.mock.js'
80-
],
74+
files: ['<%%= yeoman.client %>/{app,components}/**/*.{spec,mock}.js'],
8175
tasks: ['newer:jshint:all', 'karma']
8276
},<% if (filters.stylus) { %>
8377
injectStylus: {
84-
files: [
85-
'<%%= yeoman.client %>/{app,components}/**/*.styl'],
78+
files: ['<%%= yeoman.client %>/{app,components}/**/*.styl'],
8679
tasks: ['injector:stylus']
8780
},
8881
stylus: {
89-
files: [
90-
'<%%= yeoman.client %>/{app,components}/**/*.styl'],
82+
files: ['<%%= yeoman.client %>/{app,components}/**/*.styl'],
9183
tasks: ['stylus', 'autoprefixer']
9284
},<% } if (filters.sass) { %>
9385
injectSass: {
94-
files: [
95-
'<%%= yeoman.client %>/{app,components}/**/*.{scss,sass}'],
86+
files: ['<%%= yeoman.client %>/{app,components}/**/*.{scss,sass}'],
9687
tasks: ['injector:sass']
9788
},
9889
sass: {
99-
files: [
100-
'<%%= yeoman.client %>/{app,components}/**/*.{scss,sass}'],
90+
files: ['<%%= yeoman.client %>/{app,components}/**/*.{scss,sass}'],
10191
tasks: ['sass', 'autoprefixer']
10292
},<% } if (filters.less) { %>
10393
injectLess: {
104-
files: [
105-
'<%%= yeoman.client %>/{app,components}/**/*.less'],
94+
files: ['<%%= yeoman.client %>/{app,components}/**/*.less'],
10695
tasks: ['injector:less']
10796
},
10897
less: {
109-
files: [
110-
'<%%= yeoman.client %>/{app,components}/**/*.less'],
98+
files: ['<%%= yeoman.client %>/{app,components}/**/*.less'],
11199
tasks: ['less', 'autoprefixer']
112100
},<% } if (filters.jade) { %>
113101
jade: {
114102
files: [
115103
'<%%= yeoman.client %>/{app,components}/*',
116-
'<%%= yeoman.client %>/{app,components}/**/*.jade'],
104+
'<%%= yeoman.client %>/{app,components}/**/*.jade'
105+
],
117106
tasks: ['jade']
118107
},<% } if (filters.coffee) { %>
119108
coffee: {
120-
files: [
121-
'<%%= yeoman.client %>/{app,components}/**/*.{coffee,litcoffee,coffee.md}',
122-
'!<%%= yeoman.client %>/{app,components}/**/*.spec.{coffee,litcoffee,coffee.md}'
123-
],
109+
files: ['<%%= yeoman.client %>/{app,components}/**/!(*.spec).{coffee,litcoffee,coffee.md}'],
124110
tasks: ['newer:coffee', 'injector:scripts']
125111
},
126112
coffeeTest: {
127-
files: [
128-
'<%%= yeoman.client %>/{app,components}/**/*.spec.{coffee,litcoffee,coffee.md}'
129-
],
113+
files: ['<%%= yeoman.client %>/{app,components}/**/*.spec.{coffee,litcoffee,coffee.md}'],
130114
tasks: ['karma']
131115
},<% } %>
132116
gruntfile: {
133117
files: ['Gruntfile.js']
134118
},
135119
livereload: {
136120
files: [
137-
'{.tmp,<%%= yeoman.client %>}/{app,components}/**/*.css',
138-
'{.tmp,<%%= yeoman.client %>}/{app,components}/**/*.html',
139-
'{.tmp,<%%= yeoman.client %>}/{app,components}/**/*.js',
140-
'!{.tmp,<%%= yeoman.client %>}/{app,components}/**/*.spec.js',
141-
'!{.tmp,<%%= yeoman.client %>}/{app,components}/**/*.mock.js',
121+
'{.tmp,<%%= yeoman.client %>}/{app,components}/**/*.{css,html}',
122+
'{.tmp,<%%= yeoman.client %>}/{app,components}/**/!(*.spec|*.mock).js',
142123
'<%%= yeoman.client %>/assets/images/{,*//*}*.{png,jpg,jpeg,gif,webp,svg}'
143124
],
144125
options: {
145126
livereload: true
146127
}
147128
},
148129
express: {
149-
files: [
150-
'server/**/*.{js,json}'
151-
],
130+
files: ['server/**/*.{js,json}'],
152131
tasks: ['express:dev', 'wait'],
153132
options: {
154133
livereload: true,
@@ -167,27 +146,17 @@ module.exports = function (grunt) {
167146
options: {
168147
jshintrc: 'server/.jshintrc'
169148
},
170-
src: [
171-
'server/**/*.js',
172-
'!server/**/*.{spec,integration}.js'
173-
]
149+
src: ['server/**/!(*.spec|*.integration).js']
174150
},
175151
serverTest: {
176152
options: {
177153
jshintrc: 'server/.jshintrc-spec'
178154
},
179155
src: ['server/**/*.{spec,integration}.js']
180156
},
181-
all: [
182-
'<%%= yeoman.client %>/{app,components}/**/*.js',
183-
'!<%%= yeoman.client %>/{app,components}/**/*.spec.js',
184-
'!<%%= yeoman.client %>/{app,components}/**/*.mock.js'
185-
],
157+
all: ['<%%= yeoman.client %>/{app,components}/**/!(*.spec|*.mock).js'],
186158
test: {
187-
src: [
188-
'<%%= yeoman.client %>/{app,components}/**/*.spec.js',
189-
'<%%= yeoman.client %>/{app,components}/**/*.mock.js'
190-
]
159+
src: ['<%%= yeoman.client %>/{app,components}/**/*.{spec,mock}.js']
191160
}
192161
},
193162

@@ -198,7 +167,6 @@ module.exports = function (grunt) {
198167
main: {
199168
files: {
200169
src: [
201-
'<%%= yeoman.client %>/app/**/*.js',
202170
'<%%= yeoman.client %>/app/**/*.js',
203171
'server/**/*.js'
204172
]
@@ -213,10 +181,7 @@ module.exports = function (grunt) {
213181
dot: true,
214182
src: [
215183
'.tmp',
216-
'<%%= yeoman.dist %>/*',
217-
'!<%%= yeoman.dist %>/.git*',
218-
'!<%%= yeoman.dist %>/.openshift',
219-
'!<%%= yeoman.dist %>/Procfile'
184+
'<%%= yeoman.dist %>/**/!(.git*|.openshift|Procfile)'
220185
]
221186
}]
222187
},
@@ -285,8 +250,7 @@ module.exports = function (grunt) {
285250
filerev: {
286251
dist: {
287252
src: [
288-
'<%%= yeoman.dist %>/client/!(bower_components)/{,*/}*.js',
289-
'<%%= yeoman.dist %>/client/!(bower_components)/{,*/}*.css',
253+
'<%%= yeoman.dist %>/client/!(bower_components)/{,*/}*.{js,css}',
290254
'<%%= yeoman.dist %>/client/assets/images/{,*/}*.{png,jpg,jpeg,gif,webp,svg}',
291255
'<%%= yeoman.dist %>/client/assets/fonts/*'
292256
]
@@ -516,11 +480,7 @@ module.exports = function (grunt) {
516480
mocha_istanbul: {
517481
unit: {
518482
options: {
519-
excludes: [
520-
'**/*.spec.js',
521-
'**/*.mock.js',
522-
'**/*.integration.js'
523-
],
483+
excludes: ['**/*.{spec,mock,integration}.js'],
524484
reporter: 'spec',
525485
require: ['mocha.conf.js'],
526486
mask: '**/*.spec.js',
@@ -530,11 +490,7 @@ module.exports = function (grunt) {
530490
},
531491
integration: {
532492
options: {
533-
excludes: [
534-
'**/*.spec.js',
535-
'**/*.mock.js',
536-
'**/*.integration.js'
537-
],
493+
excludes: ['**/*.{spec,mock,integration}.js'],
538494
reporter: 'spec',
539495
require: ['mocha.conf.js'],
540496
mask: '**/*.integration.js',
@@ -592,9 +548,7 @@ module.exports = function (grunt) {
592548
files: [{
593549
expand: true,
594550
cwd: '<%%= yeoman.client %>',
595-
src: [
596-
'{app,components}/**/*.jade'
597-
],
551+
src: ['{app,components}/**/*.jade'],
598552
dest: '.tmp',
599553
ext: '.html'
600554
}]
@@ -611,10 +565,7 @@ module.exports = function (grunt) {
611565
files: [{
612566
expand: true,
613567
cwd: 'client',
614-
src: [
615-
'{app,components}/**/*.coffee',
616-
'!{app,components}/**/*.spec.coffee'
617-
],
568+
src: ['{app,components}/**/!(*.spec).coffee'],
618569
dest: '.tmp',
619570
ext: '.js'
620571
}]
@@ -630,10 +581,7 @@ module.exports = function (grunt) {
630581
files: [{
631582
expand: true,
632583
cwd: '<%%= yeoman.client %>',
633-
src: [
634-
'{app,components}/**/*.js',
635-
'!{app,components}/**/*.spec.js'
636-
],
584+
src: ['{app,components}/**/!(*.spec).js'],
637585
dest: '.tmp'
638586
}]
639587
}
@@ -707,11 +655,9 @@ module.exports = function (grunt) {
707655
files: {
708656
'<%%= yeoman.client %>/index.html': [
709657
[<% if(filters.babel) { %>
710-
'.tmp/{app,components}/**/*.js',<% } else { %>
711-
'{.tmp,<%%= yeoman.client %>}/{app,components}/**/*.js',<% } %>
712-
'!{.tmp,<%%= yeoman.client %>}/app/app.js',
713-
'!{.tmp,<%%= yeoman.client %>}/{app,components}/**/*.spec.js',
714-
'!{.tmp,<%%= yeoman.client %>}/{app,components}/**/*.mock.js'
658+
'.tmp/{app,components}/**/!(*.spec|*.mock).js',<% } else { %>
659+
'{.tmp,<%%= yeoman.client %>}/{app,components}/**/!(*.spec|*.mock).js',<% } %>
660+
'!{.tmp,<%%= yeoman.client %>}/app/app.js'
715661
]
716662
]
717663
}

0 commit comments

Comments
 (0)