-
Notifications
You must be signed in to change notification settings - Fork 74
/
Copy pathgulpfile.js
68 lines (62 loc) · 1.89 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 path = require('path');
var glob = require('glob');
var gulp = require('gulp');
var source = require('vinyl-source-stream');
var buffer = require('vinyl-buffer');
var gutil = require('gulp-util');
var argv = require('yargs').argv;
var gulpif = require('gulp-if');
var rename = require('gulp-rename');
var jshint = require('gulp-jshint');
var yuidoc = require('gulp-yuidoc');
var browserify = require('browserify');
var uglify = require('gulp-uglify');
var sourcemaps = require('gulp-sourcemaps');
// var qunit = require('node-qunit-phantomjs');
var qunit = require('gulp-qunit');
gulp.task('doc', function() {
return gulp.src(["index.js", "./src/**/*.js"])
.pipe(yuidoc.parser())
.pipe(yuidoc.reporter())
.pipe(yuidoc.generator())
.pipe(gulp.dest('./doc/api'));
});
gulp.task('lint', function() {
return gulp.src('./src/**/*.js')
.pipe(jshint())
.pipe(jshint.reporter('default'));
});
gulp.task('build', ['lint'], function() {
return browserify({
entries: './browser.js',
debug: true
}).bundle()
.pipe(source('substance.js'))
.pipe(buffer())
.pipe(sourcemaps.init({loadMaps: true}))
.pipe(gulpif(argv.production, uglify()))
.pipe(gulpif(argv.production, rename({suffix: '.min'})))
.on('error', gutil.log)
.pipe(sourcemaps.write('./'))
.pipe(gulp.dest('./dist'));
});
gulp.task('build-test', function() {
return glob("test/**/*.test.js", {}, function (err, testfiles) {
browserify({ debug: true })
.add(testfiles.map(function(file) {
return path.join(__dirname, file);
}))
.bundle()
.pipe(source('test.js'))
.pipe(buffer())
.pipe(sourcemaps.init({loadMaps: true}))
.on('error', gutil.log)
.pipe(sourcemaps.write('./'))
.pipe(gulp.dest('./test/tmp'));
});
});
gulp.task('test', ['build-test'], function() {
return gulp.src('./test/index.html')
.pipe(qunit());
});
gulp.task('default', ['build']);