From 87217e03f6ea0f2b632e7ceb0577120ee44d90e8 Mon Sep 17 00:00:00 2001 From: Douglas Duteil Date: Thu, 29 May 2014 14:47:31 +0200 Subject: [PATCH] chore(build): reduce copy time Use `gulp-changed` to copy only changed files. --- lib/build.js | 53 ++++++++++++++++++++++++++++++++++++++-------------- package.json | 1 + 2 files changed, 40 insertions(+), 14 deletions(-) diff --git a/lib/build.js b/lib/build.js index 7fc25eb..7e3db3f 100644 --- a/lib/build.js +++ b/lib/build.js @@ -2,8 +2,9 @@ var cm = require('./common'); var gulp = require('gulp'); -var path = require('path'); +var path = require('path'); var rename = require('gulp-rename'); +var changed = require('gulp-changed'); var DIR = cm.BUILD_DIR; @@ -12,27 +13,33 @@ module.exports = { bower: function (done, bwrData) { var almostDone = cm._.after(5, done); + var destination = DIR + '/bower/'; gulp.src('./branch/bower/.travis.yml') - .pipe(gulp.dest(DIR + '/bower/')) + .pipe(changed(destination)) + .pipe(gulp.dest(destination)) .on('end', almostDone); gulp.src('./branch/bower/bower.tmpl.json') - .pipe(cm.processTemplateFile({ bwr : cm._.assign({}, cm.bwr, bwrData) })) + .pipe(changed(destination)) + .pipe(cm.processTemplateFile({ bwr: cm._.assign({}, cm.bwr, bwrData) })) .pipe(rename('bower.json')) - .pipe(gulp.dest(DIR + '/bower/')) + .pipe(gulp.dest(destination)) .on('end', almostDone); gulp.src(path.join('../../dist/', cm.public.main_dist_dir || '') + '/**') - .pipe(gulp.dest(DIR + '/bower/')) + .pipe(changed(destination)) + .pipe(gulp.dest(destination)) .on('end', almostDone); gulp.src('../../CHANGELOG.md') - .pipe(gulp.dest(DIR + '/bower/')) + .pipe(changed(destination)) + .pipe(gulp.dest(destination)) .on('end', almostDone); gulp.src('../../LICENCE') - .pipe(gulp.dest(DIR + '/bower/')) + .pipe(changed(destination)) + .pipe(gulp.dest(destination)) .on('end', almostDone); }, @@ -44,24 +51,29 @@ module.exports = { var destination = DIR + '/subbower/' + moduleName; gulp.src('./branch/bower/.travis.yml') + .pipe(changed(destination)) .pipe(gulp.dest(destination)) .on('end', almostDone); gulp.src('./branch/bower/bower.tmpl.json') - .pipe(cm.processTemplateFile({ bwr : cm._.assign({}, cm.bwr, bwrData) })) + .pipe(changed(destination)) + .pipe(cm.processTemplateFile({ bwr: cm._.assign({}, cm.bwr, bwrData) })) .pipe(rename('bower.json')) .pipe(gulp.dest(destination)) .on('end', almostDone); gulp.src(path.join('../../dist/', cm.public.sub_dist_dir || '', moduleName) + '/**') + .pipe(changed(destination)) .pipe(gulp.dest(destination)) .on('end', almostDone); gulp.src('../../CHANGELOG.md') + .pipe(changed(destination)) .pipe(gulp.dest(destination)) .on('end', almostDone); gulp.src('../../LICENCE') + .pipe(changed(destination)) .pipe(gulp.dest(destination)) .on('end', almostDone); }; @@ -72,34 +84,47 @@ module.exports = { if (!cm.public.tocopy) cm.public.tocopy = []; var almostDone = cm._.after(5 + cm.public.tocopy.length, done); + var destination; + destination = DIR + '/gh-pages/vendor'; cm.public.tocopy .map(function (file) { gulp.src('../../' + file) - .pipe(gulp.dest(DIR + '/gh-pages/vendor')) + .pipe(changed(destination)) + .pipe(gulp.dest(destination)) .on('end', almostDone); }); + destination = DIR + '/gh-pages/core'; gulp.src('./branch/gh-pages/core/**') - .pipe(gulp.dest(DIR + '/gh-pages/core')) + .pipe(changed(destination)) + .pipe(gulp.dest(destination)) .on('end', almostDone); + destination = DIR + '/gh-pages/assets'; gulp.src('./branch/gh-pages/assets/**') - .pipe(gulp.dest(DIR + '/gh-pages/assets')) + .pipe(changed(destination)) + .pipe(gulp.dest(destination)) .on('end', almostDone); + destination = DIR + '/gh-pages/demo'; gulp.src('../../demo/**') - .pipe(gulp.dest(DIR + '/gh-pages/demo')) + .pipe(changed(destination)) + .pipe(gulp.dest(destination)) .on('end', almostDone); + destination = DIR + '/gh-pages/dist'; gulp.src(path.join('../../dist/', cm.public.main_dist_dir || '') + '/**') - .pipe(gulp.dest(DIR + '/gh-pages/dist')) + .pipe(changed(destination)) + .pipe(gulp.dest(destination)) .on('end', almostDone); + destination = DIR + '/gh-pages/'; gulp.src('./branch/gh-pages/index.tmp.html') + .pipe(changed(destination, {extension: '.html'})) .pipe(cm.processTemplateFile()) .pipe(rename('index.html')) - .pipe(gulp.dest(DIR + '/gh-pages/')) + .pipe(gulp.dest(destination)) .on('end', almostDone); } diff --git a/package.json b/package.json index 0524f24..6615a6f 100644 --- a/package.json +++ b/package.json @@ -7,6 +7,7 @@ "dateformat": "*", "event-stream": "*", "gulp": "*", + "gulp-changed": "^0", "gulp-rename": "*", "gulp-rimraf": "*", "gulp-util": "*",