don't compile files if they haven't changed

This commit is contained in:
Sebastian McKenzie 2015-11-05 11:46:48 +00:00
parent 5d61840c10
commit 09479378d3
2 changed files with 23 additions and 14 deletions

View File

@ -1,26 +1,33 @@
var cached = require("gulp-cached");
var through = require("through2");
var rename = require("gulp-rename");
var chalk = require("chalk");
var newer = require("gulp-newer");
var babel = require("gulp-babel");
var watch = require("gulp-watch");
var gutil = require("gulp-util");
var gulp = require("gulp");
var path = require("path");
var scripts = "./packages/*/src/**/*.js";
var dest = "packages";
gulp.task("default", ["build"]);
gulp.task("build", function () {
return gulp.src(scripts)
.pipe(cached("babel"))
.pipe(babel())
.pipe(rename(function (file) {
console.log("Compiling " + path.join(
file.dirname,
file.basename + file.extname
));
file.dirname = file.dirname.replace(/^([^\\]+)\/src/, "$1/lib");
}))
.pipe(gulp.dest("packages"));
.pipe(newer(dest))
.pipe(through.obj(function (file, enc, callback) {
gutil.log("Compiling", "'" + chalk.cyan(file.path) + "'...");
callback(null, file);
}))
.pipe(babel())
.on("error", function (err) {
console.error(err.stack);
})
.pipe(gulp.dest(dest));
});
gulp.task("watch", ["build"], function (callback) {

View File

@ -15,8 +15,9 @@
"fs-readdir-recursive": "^0.1.2",
"gulp": "^3.9.0",
"gulp-babel": "^5.3.0",
"gulp-cached": "^1.1.0",
"gulp-newer": "^1.0.0",
"gulp-rename": "^1.2.2",
"gulp-util": "^3.0.7",
"gulp-watch": "^4.3.5",
"istanbul": "^0.3.5",
"lodash": "^3.10.0",
@ -29,6 +30,7 @@
"rimraf": "^2.4.1",
"semver": "^5.0.0",
"shelljs": "^0.5.1",
"through2": "^2.0.0",
"uglify-js": "^2.4.16"
},
"babel": {