forked from sebpiq/WebPd
-
Notifications
You must be signed in to change notification settings - Fork 0
/
gulpfile.js
88 lines (75 loc) · 2.56 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
var path = require('path')
, gulp = require('gulp')
, rename = require('gulp-rename')
, gutil = require('gulp-util')
, file = require('gulp-file')
, browserify = require('browserify')
, uglify = require('gulp-uglify')
, mustache = require('mustache')
, concat = require('gulp-concat')
, contribs = require('gulp-contribs')
, runSequence = require('run-sequence')
, source = require('vinyl-source-stream')
var libWatcher, browserTestWatcher
gulp.task('lib.browserify', function() {
return browserify({ entries: './index.js' })
.bundle()
.on('error', gutil.log)
.pipe(source('webpd-latest.js'))
.pipe(gulp.dest('./build'))
})
gulp.task('lib.concat', function() {
return gulp.src(['./deps/AudioContextMonkeyPatch.js', './build/webpd-latest.js'])
.pipe(concat('webpd-latest.js'))
.pipe(gulp.dest('./dist'))
})
gulp.task('lib.build', function() {
return runSequence('lib.browserify', 'lib.concat')
})
gulp.task('lib.uglify', function() {
return gulp.src('./dist/webpd-latest.js')
.pipe(uglify())
.on('error', gutil.log)
.pipe(rename('webpd-latest.min.js'))
.pipe(gulp.dest('./dist'))
})
gulp.task('lib.objectList', function() {
var library = {}
, rendered
require('./lib/index').declareObjects(library)
rendered = mustache.render(
'{{#objects}}- {{{.}}}\n{{/objects}}',
{ objects: Object.keys(library).sort() }
)
return file('OBJECTLIST.md', rendered, { src: true })
.pipe(gulp.dest('.'))
})
gulp.task('authors', function () {
return gulp.src('AUTHORS.md')
.pipe(contribs('Authors\n----------', ' '))
.on('error', gutil.log)
.pipe(gulp.dest('.'))
})
gulp.task('test.browser.copy', function(){
return gulp.src('./dist/webpd-latest.js')
.pipe(rename('lib-build.js'))
.pipe(gulp.dest('./waatest'))
})
gulp.task('test.browser.browserify', function() {
return browserify({ entries: './test/browser/index.js', debug: true })
.bundle()
.on('error', gutil.log)
.pipe(source('test-build.js'))
.pipe(gulp.dest('./waatest'))
})
gulp.task('test.browser.build', function(done) {
libWatcher = gulp.watch(['*.js', './lib/**/*.js'], ['lib.build'])
libWatcher.on('change', function(event) {
console.log('File '+event.path+' was '+event.type+', running tasks...')
})
browserTestWatcher = gulp.watch(['./test/**/*.js', 'waatest/lib-build.js'], ['test.browser.browserify'])
browserTestWatcher.on('change', function(event) {
console.log('File '+event.path+' was '+event.type+', running tasks...')
})
return runSequence('lib.build', 'test.browser.browserify', done)
})