forked from adamhooper/js-priority-queue
-
Notifications
You must be signed in to change notification settings - Fork 0
/
gulpfile.coffee
62 lines (54 loc) · 1.6 KB
/
gulpfile.coffee
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
browserify = require('browserify')
coffeeify = require('coffeeify')
del = require('del')
gulp = require('gulp')
gutil = require('gulp-util')
KarmaServer = require('karma').Server
mocha = require('gulp-mocha')
rename = require('gulp-rename')
source = require('vinyl-source-stream')
uglify = require('gulp-uglify')
derequire = require('gulp-derequire')
gulp.task 'clean', (done) ->
del('./priority-queue*.js', done)
gulp.task 'browserify', [ 'clean' ], ->
b = browserify('./src/PriorityQueue.coffee', {
extensions: [ '.js', '.coffee' ]
standalone: 'PriorityQueue'
})
b.transform(coffeeify)
b.bundle()
.on('error', (e) -> gutil.log('Browserify error', e))
.pipe(source('priority-queue.js'))
.pipe(derequire())
.pipe(gulp.dest('.'))
gulp.task 'minify', [ 'browserify' ], ->
gulp.src('priority-queue.js')
.pipe(uglify())
.pipe(rename(suffix: '.min'))
.pipe(gulp.dest('.'))
gulp.task 'test-browser', (done) ->
new KarmaServer({
singleRun: true
browsers: [ 'PhantomJS' ]
frameworks: [ 'browserify', 'mocha', 'chai' ]
reporters: [ 'dots' ]
files: [ 'test/**/*Spec.coffee' ]
browserify:
debug: true
extensions: [ '.js', '.coffee' ]
transform: [ 'coffeeify' ]
preprocessors:
'test/**/*Spec.coffee': 'browserify'
}, done).start()
gulp.task 'test-node', (done) ->
gulp.src('test/**/*Spec.coffee', read: false)
.pipe(mocha({
compilers: [
coffee: 'coffee-script/register'
]
reporter: 'dot'
}))
.on('error', gutil.log)
gulp.task 'test', [ 'test-browser', 'test-node' ]
gulp.task('default', [ 'minify' ])