forked from DarkPark/stb
-
Notifications
You must be signed in to change notification settings - Fork 0
/
gulpfile.js
94 lines (80 loc) · 2.08 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
/**
* Gulp main entry point.
*
* @author Stanislav Kalashnik <[email protected]>
* @license GNU GENERAL PUBLIC LICENSE Version 3
*/
'use strict';
var path = require('path'),
gulp = require('gulp'),
plumber = require('gulp-plumber'),
eslint = require('gulp-eslint'),
webpack = require('webpack-stream'),
log = require('gulp-util').log;
// enable colors in console
require('tty-colors');
// check for potential errors and problems
gulp.task('lint', function () {
return gulp
.src([
'./bin/**/*.js',
'./tpl/**/*.js'
])
.pipe(plumber())
.pipe(eslint())
.pipe(eslint.format('stylish', function ( result ) {
// make nice output
result.split('\n').forEach(function ( line ) {
log('eslint '.bgRed, line + ''.reset);
});
}));
});
// build source files
gulp.task('webpack', function () {
return gulp
.src('tests/units/**/*.js')
.pipe(plumber())
.pipe(webpack({
output: {
filename: 'build.js',
pathinfo: true,
sourcePrefix: '\t\t\t'
},
resolve: {
root: path.join(__dirname, 'app', 'js')
},
devtool: 'source-map',
plugins: [
// fix compilation persistence
new webpack.webpack.optimize.OccurenceOrderPlugin(true),
// global constants
new webpack.webpack.DefinePlugin({
DEBUG: false
})
]
}, null/*, report*/))
.pipe(gulp.dest('tests'));
});
// build documentation
gulp.task('jsdoc', function ( done ) {
// run process
var child = require('child_process').spawn(
'./node_modules/.bin/jsdoc',
['--recurse', '--configure', 'jsdoc.json', '--destination', '../stb-pages/', 'tpl/app/js/stb/', 'readme.md']
);
child.on('close', done);
child.on('error', function reportError () {
console.log('FATAL ERROR: JSDoc failed to start!');
});
child.stderr.on('data', function reportStdErr ( data ) {
console.log(data);
});
child.stdout.on('data', function reportStdOut ( data ) {
console.log(data);
});
});
// entry point
gulp.task('default', ['webpack', 'jsdoc'], function () {
gulp.watch(['./app/js/**/*.js', './tests/units/**/*.js'], ['webpack']);
gulp.watch(['./app/js/**/*.js'], ['jsdoc']);
});