diff --git a/Gulpfile.js b/Gulpfile.js index e64e30a2f6..7fdf613bde 100644 --- a/Gulpfile.js +++ b/Gulpfile.js @@ -1,26 +1,33 @@ -var cached = require("gulp-cached"); -var rename = require("gulp-rename"); -var babel = require("gulp-babel"); -var watch = require("gulp-watch"); -var gulp = require("gulp"); -var path = require("path"); +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) { diff --git a/package.json b/package.json index 464a093b94..bf070327f0 100644 --- a/package.json +++ b/package.json @@ -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": {