-
Notifications
You must be signed in to change notification settings - Fork 20
/
Copy pathGruntfile.coffee
140 lines (126 loc) · 2.94 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
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
# Build configurations.
module.exports = (grunt) ->
grunt.loadNpmTasks 'grunt-karma'
grunt.loadNpmTasks 'grunt-contrib-connect'
grunt.loadNpmTasks 'grunt-contrib-watch'
grunt.loadNpmTasks 'grunt-contrib-coffee'
grunt.loadNpmTasks 'grunt-contrib-jshint'
grunt.loadNpmTasks 'grunt-contrib-concat'
grunt.loadNpmTasks 'grunt-contrib-uglify'
grunt.initConfig
connect:
app:
options:
base: './src/'
middleware: require './server/middleware'
port: 5001
watch:
options:
livereload: false
karma:
unit:
options:
autoWatch: true
colors: true
configFile: './test/karma.conf.js'
keepalive: true
port: 8081
runnerPort: 9100
travis:
options:
colors: true
configFile: './test/karma.conf.js'
runnerPort: 9100
singleRun: true
# transpile CoffeeScript (.coffee) files to JavaScript (.js).
coffee:
build:
files: [
cwd: './src'
src: '*.coffee'
dest: './temp/'
expand: true
ext: '.js'
]
options:
bare: true
#sourceMap: true
#prepend 'use strict' to the files
concat:
#usestrict:
options:
banner: '(function () {\n\'use strict\';\n'
footer: '}());'
stripBanners: true
process: (src, filepath) ->
console.log("Processing #{filepath} ...")
strings = /("(?:(?:\\")|[^"])*")/g
singleQuotes = /'/g
src.replace(strings,
(match) ->
console.log("match: " + match)
result = "'" + match.substring(1, match.length-1).replace(singleQuotes, "\\'") + "'"
console.log "replaced with: " + result
result
)
dynamic_mappings:
files:
'dist/ui-scroll.js': ['./temp/**/ui-scroll.js']
'dist/ui-scroll-jqlite.js': ['./temp/**/ui-scroll-jqlite.js']
uglify:
common:
files:
'./dist/ui-scroll.min.js': [
'./dist/ui-scroll.js'
]
'./dist/ui-scroll-jqlite.min.js': [
'./dist/ui-scroll-jqlite.js'
]
# run the linter
jshint:
dist:
files:
src: ['./dist/ui-scroll.js', './dist/ui-scroll-jqlite.js']
options: jshintrc: '.jshintrc'
test:
files:
src : [ './test/*Spec.js']
options: grunt.util._.extend({}, grunt.file.readJSON('.jshintrc'), {
node: true
globals:
angular: false
inject: false
jQuery: false
jasmine: false
afterEach: false
beforeEach: false
ddescribe: false
describe: false
expect: false
iit: false
it: false
spyOn: false
xdescribe: false
xit: false
})
# Starts a web server
# Enter the following command at the command line to execute this task:
# grunt server
grunt.registerTask 'server', [
'connect'
'watch'
]
grunt.registerTask 'default', ['server']
grunt.registerTask 'test', [
'karma:unit'
]
grunt.registerTask 'build', [
'jshint:test'
'karma:travis'
'coffee:build'
'concat'
'jshint:dist'
'uglify:common']
grunt.registerTask 'travis', [
'karma:travis'
]