-
Notifications
You must be signed in to change notification settings - Fork 5
/
gulpfile.js
131 lines (111 loc) · 2.87 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
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
'use strict';
const gulp = require('gulp');
const Server = require('karma').Server;
const pkg = require('./package.json');
const plugins = require('gulp-load-plugins')();
const runSequence = require('run-sequence');
const del = require('del');
const stylish = require('jshint-stylish');
const jsdocConfig = require('./jsdoc-config.json');
const mainFiles = [
'src/kairos.js',
'src/Lexicon.js',
'src/Engine.js'
];
gulp.task('init', () => {
return plugins.bower();
});
gulp.task('build', done => {
return runSequence('clean', 'build-raw', 'build-min', 'build-debug', 'build-nodejs', done);
});
gulp.task('build-raw', () => {
return gulp.src(mainFiles)
.pipe(plugins.concat('kairos.js'))
.pipe(banner())
.pipe(plugins.stripDebug())
.pipe(gulp.dest('build'));
});
gulp.task('build-min', () => {
return gulp.src(mainFiles)
.pipe(plugins.uglify({
preserveComments: 'some'
}))
.pipe(plugins.concat('kairos-min.js'))
.pipe(banner())
.pipe(plugins.stripDebug())
.pipe(gulp.dest('build'));
});
gulp.task('build-debug', () => {
return gulp.src(mainFiles)
.pipe(plugins.concat('kairos-debug.js'))
.pipe(banner())
.pipe(gulp.dest('build'));
});
gulp.task('build-nodejs', () => {
return gulp.src('src/kairos.js')
.pipe(plugins.include())
.on('error', console.log)
.pipe(plugins.concat('kairos-node.js'))
.pipe(banner())
.pipe(gulp.dest('build'));
});
gulp.task('clean', done => {
del(['build']).then(() => {
done();
});
});
gulp.task('docs', cb => {
gulp.src(['README.md', './src/**/*.js'], {read: false})
.pipe(plugins.jsdoc3(jsdocConfig, cb));
});
gulp.task('format', () => {
return gulp.src(['src/**/*.js'])
.pipe(plugins.esformatter())
.pipe(gulp.dest('src'));
});
gulp.task('lint', () => {
return gulp.src(['src/**/*.js'])
.pipe(plugins.jshint())
.pipe(plugins.jshint.reporter(stylish))
.pipe(plugins.jshint.reporter('fail'));
});
gulp.task('serve', () => {
return gulp.src('./')
.pipe(plugins.webserver({
directoryListing: true,
open: true,
port: process.env.PORT || '8000',
host: process.env.IP || 'localhost'
}));
});
gulp.task('watch', ['build', 'serve'], () => {
gulp.watch(['src/**/*'], ['build']);
});
gulp.task('test', done => {
new Server({
configFile: __dirname + '/karma.conf.js',
singleRun: true
}).start(done);
});
gulp.task('test-watch', done => {
new Server({
configFile: __dirname + '/karma.conf.js'
}).start(done);
});
// Private helpers
// ===============
function banner() {
let stamp = [
'/**',
' * Kairos.js - <%= pkg.description %>',
' * @author <%= pkg.author.name %> <<%= pkg.author.email %>>',
' * @version v<%= pkg.version %>',
' * @link https://github.com/kairos',
' * @license BSD-2-Clause',
' */',
''
].join('\n');
return plugins.header(stamp, {
pkg: pkg
});
}