-
Notifications
You must be signed in to change notification settings - Fork 0
/
gulpfile.js
73 lines (64 loc) · 1.68 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
67
68
69
70
71
72
73
var gulp = require('gulp');
var cheerio = require('gulp-cheerio');
var gimporter = require('./lib/gimporter');
var indexer = require('./lib/indexer');
var elastic = require('./lib/elastic');
var eslint = require('gulp-eslint');
var gutil = require('gulp-util');
var chalk = require('chalk');
gulp.task('import', function () {
return gulp
.src(['xml/**/*.*', '!xml/**/{POPUP,POPUP/**}'])
.pipe(cheerio({
parserOptions: {
xmlMode: true
},
run: function ($, file, done) {
gutil.log(chalk.yellow('Processing:', file.path));
gimporter.processFile($, file)
.then(function () {
done();
});
} }));
});
gulp.task('process_template', function () {
elastic.setTemplate();
});
gulp.task('index', function () {
indexer.perform();
});
gulp.task('reindex', function () {
indexer.reindex();
});
gulp.task('lint', function () {
return gulp.src(['**/*.js', '!node_modules/**'])
.pipe(eslint())
.pipe(eslint.format())
.pipe(eslint.results(function (result) {
if (!result.errorCount) {
gutil.log(chalk.green('No errors found'));
}
}))
.pipe(eslint.failAfterError());
});
gulp.task('lint-watch', function () {
var lintAndPrint = eslint();
lintAndPrint
.pipe(eslint.formatEach())
.pipe(eslint.result(function (result) {
if (!result.errorCount) {
gutil.log(chalk.green('No errors found'));
}
}));
return gulp.watch('./lib/**/*.js', function (event) {
if (event.type !== 'deleted') {
gulp.src(event.path)
.pipe(lintAndPrint, {
end: false
});
}
});
});
gulp.task('default', ['import'], function () {
process.exit();
});