-
Notifications
You must be signed in to change notification settings - Fork 2
/
Gruntfile.coffee
110 lines (101 loc) · 3.01 KB
/
Gruntfile.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
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
module.exports = (grunt) ->
coffees = (cwd, dest)->
expand: true
cwd: cwd
src: "*.coffee"
dest: dest
ext: ".js"
grunt.initConfig
pkg: grunt.file.readJSON 'package.json'
# meta:
# banner:
# "// <%= pkg.title || pkg.name %> - v<%= pkg.version %> - <%= grunt.template.today(\"yyyy-mm-dd\") %>\n
# <%= pkg.homepage ? \"// \" + pkg.homepage + \"\n\" : \"\" %>
# // Copyright (c) <%= grunt.template.today(\"yyyy\") %> <%= pkg.author.name %>;
# Licensed <%= _.pluck(pkg.licenses, \"type\").join(\", \") %>"
clean:
app:
src: ["dist", "docs"]
mochaTest:
spec:
options:
reporter: 'spec'
src: ["test/node/**/*.coffee"]
uglify:
dist:
src: ['<banner:meta.banner>', './lib/<%= pkg.name %>.js']
dest: 'lib/<%= pkg.name %>.min.js'
webpack:
stores:
entry: './src/browser.js'
output:
filename: './lib/<%= pkg.name %>.js'
resolve:
extensions: ['', ".js", ".coffee"]
module:
loaders: [
{ test: /\.coffee$/, loader: 'coffee-loader' }
]
karma:
options:
browsers: do ->
# butt - Browser Under Test Tools
butt = []
unless process.env.DEBUG
if process.env.BAMBOO
butt.push 'PhantomJS'
else if process.env.TRAVIS
butt.push 'Firefox'
else
butt.push 'Chrome'
butt
frameworks: [ 'mocha', 'sinon-chai' ]
reporters: [ 'spec', 'junit', 'coverage' ]
singleRun: true,
logLevel: 'INFO'
preprocessors:
'test/**/*.coffee': [ 'coffee' ]
junitReporter:
outputFile: 'build/reports/karma.xml'
coverageReporter:
type: 'lcov'
dir: 'build/reports/coverage/'
client:
options:
files: [
'node_modules/jefri/lib/jefri.min.js',
'node_modules/q/q.js',
'lib/<%= pkg.name %>.js',
'test/karma/**/*.coffee'
]
min:
options:
files: [
'node_modules/jefri/lib/jefri.min.js',
'node_modules/q/q.js',
'lib/<%= pkg.name %>.min.js',
'test/karma/**/*.coffee'
]
grunt.registerTask "connect", (grunt)->
mount = require('st')({ path: __dirname + '/test/contexts', url: '/' })
require('http').createServer (req, res)->
res.setHeader 'Access-Control-Allow-Origin', '*'
res.setHeader 'Access-Control-Allow-Credentials', true
res.setHeader 'Access-Control-Allow-Headers', 'Origin, X-Requested-With, Content-Type, Accept'
res.setHeader 'Access-Control-Allow-Methods', 'GET,PUT,POST,DELETE,OPTIONS'
if (mount(req, res))
return
else
res.end('this is not a static file')
.listen(8000)
grunt.loadNpmTasks "grunt-mocha-test"
grunt.loadNpmTasks "grunt-contrib-watch"
grunt.loadNpmTasks "grunt-contrib-uglify"
grunt.loadNpmTasks "grunt-contrib-concat"
grunt.loadNpmTasks "grunt-contrib-clean"
grunt.loadNpmTasks "grunt-jsonlint"
grunt.loadNpmTasks "grunt-webpack"
grunt.loadNpmTasks "grunt-karma"
grunt.loadNpmTasks "grunt-release"
grunt.registerTask "lint", []
grunt.registerTask "default", ["clean", "lint", "connect", "mochaTest", "webpack", "karma:client", "uglify", "karma:min"]