11var gulp = require ( 'gulp' ) ;
2- var runSequence = require ( "run-sequence" ) ;
32var path = require ( 'path' ) ;
43var typescript = require ( 'gulp-typescript' ) ;
54var tslint = require ( 'gulp-tslint' ) ;
@@ -15,16 +14,6 @@ var buildConfig = require('./build.config');
1514var header = require ( 'gulp-header' ) ;
1615var ngPackagr = require ( 'ng-packagr' ) ;
1716
18- //------------Main------------
19-
20- gulp . task ( 'build' , [
21- 'build.tools' ,
22- 'build.components'
23- ] ) ;
24-
25- gulp . task ( 'default' , [ 'build' ] ) ;
26-
27-
2817//------------Tools------------
2918
3019gulp . task ( 'build.tools' , function ( ) {
@@ -40,44 +29,49 @@ gulp.task('build.tools', function() {
4029
4130//------------Components------------
4231
43- gulp . task ( 'clean.metadata' , [ 'build.tools' ] , function ( ) {
32+ gulp . task ( 'clean.metadata' , gulp . series ( 'build.tools' , function ( ) {
4433 var outputFolderPath = buildConfig . tools . metadataGenerator . outputFolderPath ;
4534
4635 return del ( [ outputFolderPath ] ) ;
47- } ) ;
36+ } ) ) ;
4837
49- gulp . task ( 'generate.metadata' , [ 'build.tools' , 'clean.metadata' ] , function ( ) {
38+ gulp . task ( 'generate.metadata' , gulp . series ( 'build.tools' , 'clean.metadata' , function ( done ) {
5039 var MetadataGenerator = require ( buildConfig . tools . metadataGenerator . importFrom ) . default ,
5140 generator = new MetadataGenerator ( ) ;
5241
5342 generator . generate ( buildConfig . tools . metadataGenerator ) ;
54- } ) ;
43+ done ( ) ;
44+ } ) ) ;
5545
56- gulp . task ( 'clean.generatedComponents' , function ( ) {
46+ gulp . task ( 'clean.generatedComponents' , function ( done ) {
5747 var { outputFolderPath } = buildConfig . tools . componentGenerator ;
5848 del . sync ( [ outputFolderPath + "/**" ] ) ;
49+ done ( ) ;
5950} ) ;
6051
61- gulp . task ( 'generate.components' , [ 'generate.metadata' , 'clean.generatedComponents' ] , function ( ) {
52+ gulp . task ( 'generate.components' , gulp . series ( 'generate.metadata' , 'clean.generatedComponents' , function ( done ) {
6253 var DoTGenerator = require ( buildConfig . tools . componentGenerator . importFrom ) . default ,
6354 generator = new DoTGenerator ( ) ;
6455
6556 generator . generate ( buildConfig . tools . componentGenerator ) ;
66- } ) ;
57+ done ( ) ;
58+ } ) ) ;
6759
68- gulp . task ( 'generate.moduleFacades' , [ 'generate.components' ] , function ( ) {
60+ gulp . task ( 'generate.moduleFacades' , gulp . series ( 'generate.components' , function ( done ) {
6961 var ModuleFacadeGenerator = require ( buildConfig . tools . moduleFacadeGenerator . importFrom ) . default ,
7062 moduleFacadeGenerator = new ModuleFacadeGenerator ( ) ;
7163
7264 moduleFacadeGenerator . generate ( buildConfig . tools . moduleFacadeGenerator ) ;
73- } ) ;
65+ done ( ) ;
66+ } ) ) ;
7467
75- gulp . task ( 'generate.facades' , [ 'generate.moduleFacades' ] , function ( ) {
68+ gulp . task ( 'generate.facades' , gulp . series ( 'generate.moduleFacades' , function ( done ) {
7669 var FacadeGenerator = require ( buildConfig . tools . facadeGenerator . importFrom ) . default ,
7770 facadeGenerator = new FacadeGenerator ( ) ;
7871
7972 facadeGenerator . generate ( buildConfig . tools . facadeGenerator ) ;
80- } ) ;
73+ done ( ) ;
74+ } ) ) ;
8175
8276gulp . task ( 'build.license-headers' , function ( ) {
8377 var config = buildConfig . components ,
@@ -105,12 +99,12 @@ gulp.task('build.license-headers', function() {
10599 '\n' // This new line is necessary to keep the header after TS compilation
106100 ] . join ( '\n' ) ;
107101
108- return gulp . src ( path . join ( config . outputPath , config . srcFilesPattern ) )
102+ return gulp . src ( ` ${ config . outputPath } / ${ config . srcFilesPattern } ` )
109103 . pipe ( header ( banner , data ) )
110104 . pipe ( gulp . dest ( config . outputPath ) ) ;
111105} ) ;
112106
113- gulp . task ( 'clean.dist' , function ( ) {
107+ gulp . task ( 'clean.dist' , function ( ) {
114108 del . sync ( [ buildConfig . components . outputPath + "/*.*" ] ) ;
115109 return del ( [ buildConfig . components . outputPath ] ) ;
116110} ) ;
@@ -122,54 +116,87 @@ gulp.task('build.ngc', function() {
122116 } ) ;
123117} ) ;
124118
125- gulp . task ( 'build.copy-sources' , [ 'clean.dist' ] , function ( ) {
119+ gulp . task ( 'build.copy-sources' , gulp . series ( 'clean.dist' , function ( ) {
126120 var config = buildConfig . components ;
127- return gulp . src ( [ path . join ( config . sourcePath , '**/*.*' ) , 'package.json' ] )
121+ return gulp . src ( config . sourcesGlobs )
128122 . pipe ( gulp . dest ( config . outputPath ) ) ;
129- } ) ;
123+ } ) ) ;
130124
131125// Note: workaround for https://github.com/angular/angular-cli/issues/4874
132126gulp . task ( 'build.remove-unusable-variable' , function ( ) {
133127 var config = buildConfig . npm ;
134128
135- return gulp . src ( path . join ( config . distPath , ' **/*.js') )
129+ return gulp . src ( config . distPath + '/ **/*.js')
136130 . pipe ( replace ( / D e v E x p r e s s \. [ \w \. ] + / g, 'Object' ) )
137131 . pipe ( gulp . dest ( config . distPath ) ) ;
138132} ) ;
139133
140- gulp . task ( 'build.components' , [ 'generate.facades' ] , function ( done ) {
141- runSequence (
134+ gulp . task ( 'build.components' , gulp . series ( 'generate.facades' ,
142135 'build.copy-sources' ,
143136 'build.license-headers' ,
144137 'build.ngc' ,
145- 'build.remove-unusable-variable' ,
146- done
147- ) ;
148- } ) ;
149-
138+ 'build.remove-unusable-variable'
139+ ) ) ;
150140
151141//------------npm------------
152142
153- gulp . task ( 'npm.content' , [ 'build.components' ] , function ( ) {
143+ gulp . task ( 'npm.content' , gulp . series ( 'build.components' , function ( ) {
154144 var npmConfig = buildConfig . npm ,
155145 cmpConfig = buildConfig . components ;
156146
157- return gulp . src ( [ path . join ( cmpConfig . outputPath , ' **/collection.json') , ...npmConfig . content ] )
147+ return gulp . src ( [ cmpConfig . outputPath + '/ **/collection.json', ...npmConfig . content ] )
158148 . pipe ( gulp . dest ( npmConfig . distPath ) ) ;
149+ } ) ) ;
150+
151+ gulp . task ( 'npm.pack' , gulp . series ( 'npm.content' , shell . task ( [ 'npm pack' ] , { cwd : buildConfig . npm . distPath } ) ) ) ;
152+
153+ //------------TSLint------------
154+
155+ gulp . task ( 'lint' , function ( ) {
156+ return gulp . src ( [ buildConfig . components . tsSourcesGlob ]
157+ . concat ( buildConfig . components . tsTestSrc )
158+ . concat ( buildConfig . examples . srcFilesPattern )
159+ . concat ( buildConfig . tools . srcFilesPattern )
160+ )
161+ . pipe ( tslint ( {
162+ formatter : 'prose' ,
163+ tslint : require ( 'tslint' ) . default ,
164+ rulesDirectory : null ,
165+ configuration : 'tslint.json'
166+ } ) )
167+ . pipe ( tslint . report ( ) ) ;
159168} ) ;
160169
161- gulp . task ( 'npm.pack' , [ 'npm.content' ] , shell . task ( [ 'npm pack' ] , { cwd : buildConfig . npm . distPath } ) ) ;
170+
171+ //------------Main------------
172+
173+ var buildTask = gulp . series (
174+ 'build.tools' ,
175+ 'build.components'
176+ ) ;
177+
178+ gulp . task ( 'build' , buildTask ) ;
179+ gulp . task ( 'default' , buildTask ) ;
162180
163181
164182//------------Testing------------
165183
166- gulp . task ( 'clean.tests' , function ( ) {
184+ gulp . task ( 'clean.tests' , function ( ) {
167185 var outputFolderPath = buildConfig . components . testsPath ;
168186
169187 return del ( [ outputFolderPath ] ) ;
170188} ) ;
171189
172- gulp . task ( 'build.tests' , [ 'clean.tests' , 'generate-component-names' ] , function ( ) {
190+ gulp . task ( 'generate-component-names' , gulp . series ( 'build.tools' , function ( done ) {
191+ var ComponentNamesGenerator = require ( buildConfig . tools . componentNamesGenerator . importFrom ) . default ;
192+ var generator = new ComponentNamesGenerator ( buildConfig . tools . componentNamesGenerator ) ;
193+
194+ generator . generate ( ) ;
195+
196+ done ( ) ;
197+ } ) ) ;
198+
199+ gulp . task ( 'build.tests' , gulp . series ( 'clean.tests' , 'generate-component-names' , function ( ) {
173200 var config = buildConfig . components ,
174201 testConfig = buildConfig . tests ;
175202
@@ -178,7 +205,7 @@ gulp.task('build.tests', ['clean.tests', 'generate-component-names'], function()
178205 . pipe ( typescript ( testConfig . tsConfigPath ) )
179206 . pipe ( sourcemaps . write ( '.' ) )
180207 . pipe ( gulp . dest ( config . testsPath ) ) ;
181- } ) ;
208+ } ) ) ;
182209
183210gulp . task ( 'watch.spec' , function ( ) {
184211 gulp . watch ( buildConfig . components . tsTestSrc , [ 'build.tests' ] ) ;
@@ -193,29 +220,15 @@ var getKarmaConfig = function(testsPath) {
193220 } ) ;
194221} ;
195222
196- gulp . task ( 'test.components' , function ( done ) {
197- runSequence (
198- 'test.components.server' ,
199- 'test.components.client' ,
200- done ) ;
201- } ) ;
202-
203- gulp . task ( 'test.components.client' , [ 'build.tests' ] , function ( done ) {
223+ gulp . task ( 'test.components.client' , gulp . series ( 'build.tests' , function ( done ) {
204224 new karmaServer ( getKarmaConfig ( './karma.test.shim.js' ) , done ) . start ( ) ;
205- } ) ;
206-
207- gulp . task ( 'generate-component-names' , [ 'build.tools' ] , function ( done ) {
208- var ComponentNamesGenerator = require ( buildConfig . tools . componentNamesGenerator . importFrom ) . default ;
209- var generator = new ComponentNamesGenerator ( buildConfig . tools . componentNamesGenerator ) ;
210-
211- generator . generate ( ) ;
225+ } ) ) ;
212226
213- done ( ) ;
214- } ) ;
215-
216- gulp . task ( 'test.components.server' , [ 'build.tests' ] , function ( done ) {
227+ gulp . task ( 'test.components.server' , gulp . series ( 'build.tests' , function ( done ) {
217228 new karmaServer ( getKarmaConfig ( './karma.server.test.shim.js' ) , done ) . start ( ) ;
218- } ) ;
229+ } ) ) ;
230+
231+ gulp . task ( 'test.components' , gulp . series ( 'test.components.server' , 'test.components.client' ) ) ;
219232
220233gulp . task ( 'test.components.client.debug' , function ( done ) {
221234 var config = getKarmaConfig ( './karma.test.shim.js' ) ;
@@ -249,39 +262,12 @@ gulp.task('test.tools', function(done) {
249262 } ) ) ;
250263} ) ;
251264
252- gulp . task ( 'run.tests' , function ( done ) {
253- runSequence (
254- [ 'test.tools' , 'test.components' ] ,
255- 'lint' ,
256- done ) ;
257- } ) ;
265+ gulp . task ( 'run.tests' , gulp . series ( gulp . parallel ( 'test.tools' , 'test.components' ) ) ) ;
258266
259- gulp . task ( 'test' , function ( done ) {
260- runSequence (
261- 'build' , 'build.tests' , 'run.tests' ,
262- done ) ;
263- } ) ;
267+ gulp . task ( 'test' , gulp . series ( 'build' , 'build.tests' , 'run.tests' ) ) ;
264268
265269gulp . task ( 'watch.test' , function ( done ) {
266270 new karmaServer ( {
267271 configFile : __dirname + '/karma.conf.js'
268272 } , done ) . start ( ) ;
269273} ) ;
270-
271-
272- //------------TSLint------------
273-
274- gulp . task ( 'lint' , function ( ) {
275- return gulp . src ( [ path . join ( buildConfig . components . sourcePath , buildConfig . components . srcFilesPattern ) ]
276- . concat ( buildConfig . components . tsTestSrc )
277- . concat ( buildConfig . examples . srcFilesPattern )
278- . concat ( buildConfig . tools . srcFilesPattern )
279- )
280- . pipe ( tslint ( {
281- formatter : 'prose' ,
282- tslint : require ( 'tslint' ) . default ,
283- rulesDirectory : null ,
284- configuration : 'tslint.json'
285- } ) )
286- . pipe ( tslint . report ( ) ) ;
287- } ) ;
0 commit comments