build(gulp): fix incremental compilation by reusing angularBuilder across watch re-reruns

This commit is contained in:
Igor Minar 2015-04-27 00:46:48 -07:00
parent d1ec2e18cd
commit 8ea03d0380
2 changed files with 31 additions and 7 deletions

View File

@ -1,6 +1,7 @@
'use strict'; 'use strict';
var autoprefixer = require('gulp-autoprefixer'); var autoprefixer = require('gulp-autoprefixer');
var del = require('del');
var format = require('gulp-clang-format'); var format = require('gulp-clang-format');
var fork = require('child_process').fork; var fork = require('child_process').fork;
var gulp = require('gulp'); var gulp = require('gulp');
@ -81,9 +82,11 @@ var CONFIG = {
// ------------ // ------------
// clean // clean
gulp.task('build/clean.tools', clean(gulp, gulpPlugins, { gulp.task('build/clean.tools', function() {
path: path.join('dist', 'tools') if (rebuildTools && 'AngularBuilder' in global) {
})); del(path.join('dist', 'tools'));
};
});
gulp.task('build/clean.js', clean(gulp, gulpPlugins, { gulp.task('build/clean.js', clean(gulp, gulpPlugins, {
path: CONFIG.dest.js.all path: CONFIG.dest.js.all
@ -330,8 +333,17 @@ gulp.task('test.unit.cjs/ci', function(done) {
}); });
gulp.task('test.unit.cjs', ['test.unit.cjs/ci'], function () { gulp.task('test.unit.cjs', ['build/clean.js'], function (done) {
gulp.watch('modules/**', ['test.unit.cjs/ci']); function buildAndTest() {
runSequence(
'build.js.cjs',
'test.unit.cjs/ci'
);
}
buildAndTest();
gulp.watch('modules/**', buildAndTest);
}); });
@ -343,6 +355,8 @@ gulp.task('test.unit.tools/ci', function(done) {
gulp.task('test.unit.tools', function(done) { gulp.task('test.unit.tools', function(done) {
rebuildTools = true;
function buildAndTest() { function buildAndTest() {
runSequence( runSequence(
'build.tools', 'build.tools',
@ -355,6 +369,7 @@ gulp.task('test.unit.tools', function(done) {
gulp.watch('tools/**', buildAndTest); gulp.watch('tools/**', buildAndTest);
}); });
// ------------------ // ------------------
// server tests // server tests
// These tests run on the VM on the command-line and are // These tests run on the VM on the command-line and are
@ -451,8 +466,12 @@ gulp.task('build.dart', function(done) {
}); });
var rebuildTools = false;
gulp.task('build.tools', ['build/clean.tools'], function() { gulp.task('build.tools', ['build/clean.tools'], function() {
var mergedStream; if (!rebuildTools && angularBuilder.rebuildNodeTree !== throwToolsBuildMissingError) {
return;
}
var tsResult = gulp.src('tools/**/*.ts') var tsResult = gulp.src('tools/**/*.ts')
.pipe(sourcemaps.init()) .pipe(sourcemaps.init())
@ -465,7 +484,7 @@ gulp.task('build.tools', ['build/clean.tools'], function() {
var destDir = gulp.dest('dist/tools/'); var destDir = gulp.dest('dist/tools/');
mergedStream = merge2([ var mergedStream = merge2([
tsResult.js.pipe(sourcemaps.write('.')).pipe(destDir), tsResult.js.pipe(sourcemaps.write('.')).pipe(destDir),
tsResult.js.pipe(destDir) tsResult.js.pipe(destDir)
]).on('end', function() { ]).on('end', function() {

View File

@ -111,5 +111,10 @@ module.exports = function makeNodeTree(destinationPath) {
nodeTree = mergeTrees([nodeTree, typescriptTree], { overwrite: true }); nodeTree = mergeTrees([nodeTree, typescriptTree], { overwrite: true });
nodeTree = mergeTrees([nodeTree, docs, packageJsons]); nodeTree = mergeTrees([nodeTree, docs, packageJsons]);
// TODO(iminar): tree differ seems to have issues with trees created by mergeTrees, investigate!
// ENOENT error is thrown while doing fs.readdirSync on inputRoot
// in the meantime, we just do noop mv to create a new tree
nodeTree = stew.mv(nodeTree, '');
return destCopy(nodeTree, destinationPath); return destCopy(nodeTree, destinationPath);
}; };