-
Notifications
You must be signed in to change notification settings - Fork 17
/
Copy pathgulpfile.js
75 lines (67 loc) · 2.22 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
74
75
var gulp = require('gulp');
var path = require('path');
var path = require('path');
var mkdirp = require('mkdirp');
var Rsync = require('rsync');
var Promise = require('bluebird');
var eslint = require('gulp-eslint');
var watch = require('gulp-watch');
var pkg = require('./package.json');
var kibanaPluginDir = path.resolve(__dirname, '../kibana/installedPlugins/tagcloud');
var include = ['package.json', 'index.js', 'public', 'node_modules'];
var exclude = Object.keys(pkg.devDependencies).map(function (name) {
return path.join('node_modules', name);
});
function syncPluginTo(dest, done) {
mkdirp(dest, function (err) {
if (err) return done(err);
Promise.all(include.map(function (name) {
var source = path.resolve(__dirname, name);
return new Promise(function (resolve, reject) {
var rsync = new Rsync();
rsync
.source(source)
.destination(dest)
.flags('uav')
.recursive(true)
.set('delete')
.exclude(exclude)
.output(function (data) {
process.stdout.write(data.toString('utf8'));
});
rsync.execute(function (err) {
if (err) {
console.log(err);
return reject(err);
}
resolve();
});
});
}))
.then(function () {
done();
})
.catch(done);
});
}
gulp.task('sync', function (done) {
syncPluginTo(kibanaPluginDir, done);
});
gulp.task('lint', function (done) {
return gulp.src(['server/**/*.js', 'public/**/*.js', 'public/**/*.jsx'])
// eslint() attaches the lint output to the eslint property
// of the file object so it can be used by other modules.
.pipe(eslint())
// eslint.format() outputs the lint results to the console.
// Alternatively use eslint.formatEach() (see Docs).
.pipe(eslint.formatEach())
// To have the process exit with an error code (1) on
// lint error, return the stream and pipe to failOnError last.
.pipe(eslint.failOnError());
});
const batch = require('gulp-batch');
gulp.task('dev', ['sync'], function (done) {
watch(['package.json', 'index.js', 'public/**/*', 'server/**/*'], batch(function(events, done) {
gulp.start(['sync', 'lint'], done);
}));
});