-
Notifications
You must be signed in to change notification settings - Fork 46
/
Copy pathgulpfile.js
executable file
·66 lines (61 loc) · 1.64 KB
/
gulpfile.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
var gulp = require('gulp');
var eslint = require('gulp-eslint');
var plumber = require('gulp-plumber');
var notifier = require('node-notifier');
var gfi = require('gulp-file-insert');
var processhtml = require('gulp-processhtml');
var foreach = require('gulp-foreach');
var File = require('vinyl');
function returnGFI(filedata) {
var file = new File(filedata);
var tag = '/* jsFile ' + file.stem.substr(0, 2) + ' */';
var jsFile = 'src/' + file.stem + '.js';
var obj = {};
Object.defineProperty(obj, tag, {
value: jsFile,
writable: true,
enumerable: true,
configurable: true
});
console.log('Processing ' + tag + ' : ' + jsFile);
return obj;
}
gulp.task('lint', function () {
return gulp.src(['src/*.js'])
.pipe(plumber({
errorHandler: function (error) {
var taskName = 'eslint';
var title = '[task]' + taskName + ' ' + error.plugin;
var errorMsg = 'error: ' + error.message;
console.error(title + '\n' + errorMsg);
notifier.notify({
title: title,
message: errorMsg,
time: 3000
});
}
}))
.pipe(eslint({
useEslintrc: true
}))
.pipe(eslint.format())
.pipe(eslint.failOnError())
.pipe(plumber.stop());
});
gulp.task('build', function () {
return gulp.src('src/*.html')
.pipe(foreach(function (stream, file) {
return stream
.pipe(gfi(returnGFI(file)));
}))
.pipe(processhtml())
.pipe(gulp.dest('./Leaflet/'));
});
gulp.task('watch', function () {
gulp.watch('src/*.js', function () {
gulp.run('lint');
});
});
gulp.task('default', ['lint'], function () {
gulp.run('watch');
});