-
Notifications
You must be signed in to change notification settings - Fork 27
/
gulpfile.coffee
85 lines (68 loc) · 2.75 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
80
81
82
83
84
85
gulp = require("gulp")
concat = require("gulp-concat")
insert = require("gulp-insert")
path = require("path")
es = require("event-stream")
coffee = require("gulp-coffee")
gutil = require('gulp-util')
uglify = require('gulp-uglify')
rename = require('gulp-rename')
closure = require('gulp-jsclosure')
sourcemaps = require('gulp-sourcemaps')
replace = require('gulp-replace')
fs = require('fs')
bower = fs.readFileSync('./bower.json')
bowerJSON = JSON.parse(bower)
version = bowerJSON.version
###
`default` Action - Builds Angular Classy
1. Get's the names of all the classy plugins
2. Concatenates the core + all the plugins into one coffee file
3. Appends some code to register the plugins with classy
4. Outputs the coffee file (`angular-classy.coffee`)
5. Convert the CoffeeScript to a JS File (`angular-classy.js`)
6. Uglify (minify) the JS File (`angular-classy.min.js`)
###
gulp.task "default", [ "minify" ]
pluginNames = []
gulp.task "getPluginsNames", ->
buildNames = (es) ->
es.mapSync (file) ->
pluginNames.push "classy.#{path.basename(file.path, ".js")}"
file
gulp.src "./src/*.js"
.pipe buildNames(es)
gulp.task "concatAndRegisterPlugins", [ "getPluginsNames" ], ->
gulp.src ["./src/core.js", "./src/*.js"]
.pipe concat("angular-classy.js")
.pipe insert.append("\nangular.module('classy', " + JSON.stringify(pluginNames) + ");")
.pipe closure()
.pipe replace('%%VERSION%%', version)
.pipe gulp.dest("./")
gulp.task "minify", [ "concatAndRegisterPlugins" ], ->
gulp.src "./angular-classy.js"
.pipe sourcemaps.init()
.pipe uglify()
.pipe rename suffix: '.min'
.pipe sourcemaps.write("./")
.pipe gulp.dest("./")
gulp.task "watch", ["default"], -> gulp.watch "./src/*.js", ['minify']
###
`test` Action - Uses Karma
Runs tests in both Firefox and Phantom
###
karma = require('node-karma-wrapper')
karmaConfig = './test/karma.conf.js'
karmaBenchConfig = './test/karma.bench.conf.js'
karmaTest = karma(configFile: karmaConfig)
karmaBench = karma(configFile: karmaBenchConfig)
karmaPhantom = karma(configFile: karmaConfig, browsers: ['PhantomJS'])
karmaFirefox = karma(configFile: karmaConfig, browsers: ['Firefox'])
karmaBenchPhantom = karma(configFile: karmaBenchConfig, browsers: ['PhantomJS'])
karmaBenchFirefox = karma(configFile: karmaBenchConfig, browsers: ['Firefox'])
gulp.task "test", ["default"], (cb) -> karmaTest.simpleRun(cb)
gulp.task "testFirefox", ["default"], (cb) -> karmaFirefox.simpleRun(cb)
gulp.task "testPhantom", ["default"], (cb) -> karmaPhantom.simpleRun(cb)
gulp.task "bench", ["default"], (cb) -> karmaBench.simpleRun(cb)
gulp.task "benchFirefox", ["default"], (cb) -> karmaBenchPhantom.simpleRun(cb)
gulp.task "benchPhantom", ["default"], (cb) -> karmaBenchFirefox.simpleRun(cb)