This repository has been archived by the owner on Oct 2, 2021. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 5
/
gulpfile.coffee
79 lines (67 loc) · 2.12 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
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
gulp = require 'gulp'
$ = require('gulp-load-plugins')()
karma = require('karma').server
browserify = require 'browserify'
watchify = require 'watchify'
coffeeify = require 'coffeeify'
through2 = require 'through2'
del = require 'del'
pkg = require './package.json'
banner = """
/*!
* Really.js v<%= pkg.version %>
* Copyright (C) 2014-2015 Really Inc. <http://really.io>
*
* Date: #{$.util.date()}
*/
"""
gulp.task 'tdd', ['lint'], (done) ->
gulp.watch ['./src/**/*.coffee', './tests/**/*.coffee'], ['lint']
# start the server
$.nodemon
script: 'tests/support/server/index.js'
.on 'restart', ->
console.log 'restarted!'
karma.start
configFile: "#{__dirname}/karma.conf-tdd.js"
, done
gulp.task 'test', ['lint'], (done) ->
karma.start
configFile: "#{__dirname}/karma.conf.js"
, done
gulp.task 'browserify', ->
gulp.src ['src/really.coffee']
.pipe through2.obj (file, enc, next) ->
# generate browserify uncompressed bundle
browserify
entries: [file.path]
standalone: 'Really'
extensions: ['.js', '.coffee']
.transform('coffeeify')
.bundle (err, res) ->
file.contents = res
next(null, file)
.pipe $.rename 'really.js'
# add banner to file
.pipe $.header banner, {pkg}
.pipe gulp.dest 'dist'
.pipe $.uglify
preserveComments: 'some'
compress:
drop_console: true
# minified version of file
.pipe $.rename "really.#{pkg.version}.min.js"
.pipe gulp.dest 'dist'
gulp.task 'lint', ->
gulp.src ['./src/**/*.coffee', './tests/**/*.coffee']
.pipe $.coffeelint()
.pipe $.notify message: (file) ->
unless file.coffeelint.success
"Found #{file.coffeelint.errorCount} Errors and #{file.coffeelint.warningCount} Warnings"
# Clean Output Directory
gulp.task 'clean', del ['dist/*']
gulp.task 'lint-build', ->
gulp.src ['./src/**/*.coffee', './tests/**/*.coffee']
.pipe $.coffeelint.reporter('fail')
gulp.task 'build', ['clean', 'lint-build', 'browserify']
gulp.task 'default', ['build']