Add gulp-changed

This commit is contained in:
Ilya Ig. Petrov 2017-05-16 16:36:51 +05:00
parent 9943ae1d74
commit 20f5e71f9a
3 changed files with 1865 additions and 10 deletions

View File

@ -4,6 +4,7 @@ const gulp = require('gulp');
const del = require('del'); const del = require('del');
const through = require('through2'); const through = require('through2');
const PluginError = require('gulp-util').PluginError; const PluginError = require('gulp-util').PluginError;
const changed = require('gulp-changed');
const PluginName = 'Template literals'; const PluginName = 'Template literals';
@ -44,9 +45,10 @@ const templatePlugin = (context) => through.obj(function(file, encoding, cb) {
gulp.task('default', ['build']); gulp.task('default', ['build']);
gulp.task('clean', function() { gulp.task('clean', function(cb) {
return del.sync('./build'); //return del.sync('./build');
return cb();
}); });
@ -56,31 +58,48 @@ const excFolder = (name) => [`!./src/**/${name}`, `!./src/**/${name}/**/*`];
const excluded = [ ...excFolder('test') , ...excFolder('node_modules'), ...excFolder('src') ]; const excluded = [ ...excFolder('test') , ...excFolder('node_modules'), ...excFolder('src') ];
const commonWoTests = ['./src/extension-common/**/*', ...excluded]; const commonWoTests = ['./src/extension-common/**/*', ...excluded];
gulp.task('_cp-common', ['clean'], function() { const miniDst = './build/extension-mini';
const fullDst = './build/extension-full';
gulp.task('_cp-common', ['clean'], function(cb) {
let fins = 0;
const intheend = () => {
if (++fins === 2) {
cb();
}
};
gulp.src(commonWoTests) gulp.src(commonWoTests)
.pipe(changed(miniDst))
.pipe(templatePlugin(contexts.mini)) .pipe(templatePlugin(contexts.mini))
.pipe(gulp.dest('./build/extension-mini')) .pipe(gulp.dest(miniDst))
.on('end', intheend);
gulp.src(commonWoTests) gulp.src(commonWoTests)
.pipe(changed(fullDst))
.pipe(templatePlugin(contexts.full)) .pipe(templatePlugin(contexts.full))
.pipe(gulp.dest('./build/extension-full')); .pipe(gulp.dest(fullDst))
.on('end', intheend);
}); });
gulp.task('_cp-mini', ['_cp-common'], function() { gulp.task('_cp-mini', ['_cp-common'], function(cb) {
gulp.src(['./src/extension-mini/**/*', ...excluded]) gulp.src(['./src/extension-mini/**/*', ...excluded])
.pipe(changed(miniDst))
.pipe(templatePlugin(contexts.mini)) .pipe(templatePlugin(contexts.mini))
.pipe(gulp.dest('./build/extension-mini')); .pipe(gulp.dest(miniDst))
.on('end', cb);
}); });
gulp.task('_cp-full', ['_cp-common'], function() { gulp.task('_cp-full', ['_cp-common'], function(cb) {
gulp.src(['./src/extension-full/**/*', ...excluded]) gulp.src(['./src/extension-full/**/*', ...excluded])
.pipe(changed(fullDst))
.pipe(templatePlugin(contexts.full)) .pipe(templatePlugin(contexts.full))
.pipe(gulp.dest('./build/extension-full')); .pipe(gulp.dest(fullDst))
.on('end', cb);
}); });

View File

@ -14,6 +14,7 @@
"chai": "^3.5.0", "chai": "^3.5.0",
"eslint": "^3.15.0", "eslint": "^3.15.0",
"eslint-config-google": "^0.7.1", "eslint-config-google": "^0.7.1",
"gulp-changed": "^3.1.0",
"mocha": "^3.3.0", "mocha": "^3.3.0",
"sinon-chrome": "^2.2.1" "sinon-chrome": "^2.2.1"
}, },

File diff suppressed because it is too large Load Diff