-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathgulpfile.js
68 lines (60 loc) · 1.78 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
var fs = require('fs'),
exec = require('child_process').exec,
gulp = require('gulp'),
concat = require('gulp-concat'),
jshint = require('gulp-jshint'),
uglify = require('gulp-uglify'),
stylish = require('jshint-stylish'),
replace = require('gulp-replace'),
beautify = require('gulp-beautify');
gulp.task('compile', function() {
return gulp.src(['src/core.js'])
.pipe(replace(/\/\/ require ([\s-]*(.*?\.js))/g, function(match, p1) {
return fs.readFileSync(p1, 'utf8');
}))
.pipe(concat('zeppelin.js'))
.pipe(beautify({
indentSize: 2
}))
.pipe(gulp.dest('./lib/'));
});
gulp.task('minify', ['compile'], function() {
return gulp.src('./lib/zeppelin.js')
.pipe(concat('zeppelin-min.js'))
.pipe(uglify())
.pipe(gulp.dest('./lib/'));
});
gulp.task('jshint', ['compile'], function() {
return gulp.src('./lib/zeppelin.js')
.pipe(jshint())
.pipe(jshint.reporter(stylish))
.pipe(jshint.reporter('fail'));
});
gulp.task('build_tests', function() {
return gulp.src(tests)
.pipe(concat('tests.js'))
.pipe(gulp.dest('./test/'));
});
gulp.task('test', ['compile'], function() {
var path = './node_modules/mocha-phantomjs/bin/mocha-phantomjs',
options = '-R spec -p ./node_modules/phantomjs/bin/phantomjs',
command = './test/index.html';
exec(path + ' ' + options + ' ' + command, function (error, stdout, stderr) {
if (stdout) {
console.log(stdout);
} else if (stderr) {
console.error(stderr);
} else if (error) {
console.error(error);
}
});
});
gulp.task('watch', function() {
watcher = gulp.watch(['./src/*.js', './test/*.js'], {
interval: 500,
debounceDelay: 1000
}, ['test']);
});
gulp.task('build', ['compile', 'minify'], function(next) {
next();
});