--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/gulpfile.js Wed Oct 17 11:30:37 2018 +0200
@@ -0,0 +1,48 @@
+var gulp = require('gulp'),
+ concat = require('gulp-concat');
+
+var package = require("./package.json"),
+ scripts = package.scripts,
+ sources = scripts.sources;
+
+
+/** Fix pipe function */
+function fixPipe(stream) {
+ var origPipe = stream.pipe;
+ stream.pipe = function (dest) {
+ arguments[0] = dest.on('error', function (error) {
+ var nextStreams = dest._nextStreams;
+ if (nextStreams) {
+ nextStreams.forEach(function (nextStream) {
+ nextStream.emit('error', error);
+ });
+ } else if (dest.listeners('error').length === 1) {
+ throw error;
+ }
+ });
+ var nextStream = fixPipe(origPipe.apply(this, arguments));
+ (this._nextStreams || (this._nextStreams = [])).push(nextStream);
+ return nextStream;
+ };
+ return stream;
+}
+
+var origSrc = gulp.src;
+
+gulp.src = function() {
+ return fixPipe(origSrc.apply(this, arguments));
+};
+
+
+// Gulp tasks
+gulp.task('scripts', function() {
+ return gulp.src(sources, {cwd: scripts.base})
+ .pipe(concat(scripts.target.replace(/{version}/, package.version)))
+ .pipe(gulp.dest(scripts.base));
+});
+
+gulp.task('watch', function() {
+ gulp.watch(sources, {cwd: scripts.base}, ['scripts']);
+});
+
+gulp.task('default', ['scripts', 'watch']);