Skip to content

Commit

Permalink
add gulp-newer to only compile when source files have changed
Browse files Browse the repository at this point in the history
  • Loading branch information
brendankenny committed Oct 8, 2015
1 parent e76eb02 commit f2d90c4
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 4 deletions.
12 changes: 8 additions & 4 deletions gulpfile.js
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ var vinylMap = require('vinyl-map');
var rename = require('gulp-rename');
var coveralls = require('gulp-coveralls');
var path = require('path');
var newer = require('gulp-newer');

var COMPILER_PATH = 'node_modules/closurecompiler/compiler/compiler.jar';
var LIBTESS_SRC = ['./src/libtess.js', './src/**/*.js'];
Expand Down Expand Up @@ -82,11 +83,14 @@ function stripAsserts(node) {
*/
gulp.task('build-cat', () => {
return gulp.src(LIBTESS_SRC.concat('./build/node_export.js'))
.pipe(newer('./libtess.debug.js'))
// remove license at top of each file except first (which begins '@license')
.pipe(replace(/^\/\*[\s\*]+Copyright 2000[\s\S]*?\*\//m, ''))
.pipe(concat('libtess.debug.js'))
.pipe(gulp.dest('.'))

.pipe(newer('./libtess.cat.js'))

// remove asserts
.pipe(vinylMap((code, filename) => {
var stripped = rocambole.moonwalk(code.toString(), stripAsserts);
Expand All @@ -104,6 +108,7 @@ gulp.task('build-cat', () => {
*/
gulp.task('build-min', () => {
return gulp.src(LIBTESS_SRC.concat('./build/closure_exports.js'))
.pipe(newer('./libtess.min.js'))
.pipe(closureCompiler({
compilerPath: COMPILER_PATH,
fileName: 'libtess.min.js',
Expand Down Expand Up @@ -157,10 +162,10 @@ gulp.task('lint', ['build-cat'], () => {
/**
* Run full test suite over compiled libtess.
*/
gulp.task('run-tests', ['build-min'], () => {
gulp.task('test-suite', ['build-min'], () => {
return gulp.src('test/*.test.js', {read: false})
.pipe(mocha({
reporter: 'spec',
reporter: 'dot',
ui: 'tdd'
}));
});
Expand Down Expand Up @@ -254,9 +259,8 @@ gulp.task('browserify-expectations-viewer', () => {
.pipe(gulp.dest('./test/browser'));
});

gulp.task('test', ['lint', 'run-tests']);
gulp.task('test', ['lint', 'test-suite']);

// TODO(bckenny): more incremental
gulp.task('build', [
'build-cat',
'build-min',
Expand Down
1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,7 @@
"gulp-jscs": "^3.0.1",
"gulp-jshint": "^1.8.5",
"gulp-mocha": "^2.1.3",
"gulp-newer": "^0.5.1",
"gulp-rename": "^1.2.0",
"gulp-replace": "^0.5.4",
"jshint-stylish": "^2.0.1",
Expand Down

0 comments on commit f2d90c4

Please sign in to comment.