Skip to content

Commit 6ea4a9f

Browse files
authored
Fix 'gulp watch' command and also allow compilation of test files. (#672)
The compilation results of the test files are discarded... the process is just to allow the typescript compiler to pass over all files at once (rather than encountering errors one file at a time by running unit tests.)
1 parent 0f91e02 commit 6ea4a9f

File tree

1 file changed

+21
-2
lines changed

1 file changed

+21
-2
lines changed

gulpfile.js

Lines changed: 21 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,12 @@ var replace = require('gulp-replace');
3737
/****************/
3838
var paths = {
3939
src: [
40-
'src/**/*.ts'
40+
'src/**/*.ts',
41+
],
42+
43+
test: [
44+
'test/**/*.ts',
45+
'!test/integration/typescript/src/example*.ts',
4146
],
4247

4348
databaseSrc: [
@@ -52,6 +57,8 @@ var paths = {
5257
// rather than including both src and test in the lib dir.
5358
var buildProject = ts.createProject('tsconfig.json', {rootDir: 'src'});
5459

60+
var buildTest = ts.createProject('tsconfig.json');
61+
5562
var banner = `/*! firebase-admin v${pkg.version} */\n`;
5663

5764
/***********/
@@ -79,6 +86,16 @@ gulp.task('compile', function() {
7986
.pipe(gulp.dest(paths.build))
8087
});
8188

89+
/**
90+
* Task only used to capture typescript compilation errors in the test suite.
91+
* Output is discarded.
92+
*/
93+
gulp.task('compile_test', function() {
94+
return gulp.src(paths.test)
95+
// Compile Typescript into .js and .d.ts files
96+
.pipe(buildTest())
97+
});
98+
8299
gulp.task('copyDatabase', function() {
83100
return gulp.src(paths.databaseSrc)
84101
// Add headers
@@ -98,9 +115,11 @@ gulp.task('copyTypings', function() {
98115
.pipe(gulp.dest(paths.build))
99116
});
100117

118+
gulp.task('compile_all', gulp.series('compile', 'copyDatabase', 'copyTypings', 'compile_test'));
119+
101120
// Regenerates js every time a source file changes
102121
gulp.task('watch', function() {
103-
gulp.watch(paths.src, ['compile']);
122+
gulp.watch(paths.src.concat(paths.test), {ignoreInitial: false}, gulp.series('compile_all'));
104123
});
105124

106125
// Build task

0 commit comments

Comments
 (0)