-
Notifications
You must be signed in to change notification settings - Fork 2
/
Gruntfile.coffee
130 lines (116 loc) · 2.95 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
module.exports = (grunt) ->
massAlias =
(glob, base) ->
files = grunt.file.expand({ filter: 'isFile' }, glob)
regex = new RegExp(".*?/#{base}/(.*)\.js")
splitter = (file) ->
alias = file.match(regex)[1]
"#{file}:#{alias}"
files.map(splitter)
grunt.initConfig({
pkg: grunt.file.readJSON('package.json'),
coffeelint: {
app: ['src/**/*.coffee'],
options: {
configFile: 'coffeelint.json'
}
},
coffee: {
compile: {
files: [
{
expand: true,
cwd: 'src',
src: ['**/*.coffee'],
dest: 'target/brazier',
ext: '.js'
}
]
},
test: {
files: [
{
expand: true,
cwd: 'test',
src: ['**/*.coffee'],
dest: 'test/target/brazier',
ext: '.js'
}
]
}
},
copy: {
publish: {
files: [
{
src: ['target/brazier/brazier/*']
, dest: 'publish'
, expand: true
, filter: 'isFile'
, flatten: true
}
],
}
test: {
files: [
{
src: ['node_modules/qunit/qunit/*']
, dest: 'test/target/qunit'
, expand: true
, filter: 'isFile'
, flatten: true
},
],
},
},
file_append: {
default_options: {
files: [
{
append: "const QUnit = window?.QUnit; export { QUnit };",
input: 'test/target/qunit/qunit.js',
output: 'test/target/qunit/qunit.js'
}
]
}
},
connect: {
server: {
options: {
protocol: 'http',
port: 9005,
middleware: (connect, options, middlewares) ->
middlewares.unshift((req, res, next) ->
if req.url.endsWith('.js')
res.setHeader('Content-Type', 'text/javascript')
next()
)
middlewares
},
},
},
qunit: {
all: ['test/*.html'],
options: {
puppeteer: {
executablePath: "/usr/bin/snap"
ignoreDefaultArgs: true,
args: [
"run",
"chromium"
"--headless",
"--disable-web-security",
"--allow-file-access-from-files"
]
},
}
}
})
grunt.loadNpmTasks('grunt-coffeelint')
grunt.loadNpmTasks('grunt-contrib-coffee')
grunt.loadNpmTasks('grunt-contrib-connect')
grunt.loadNpmTasks('grunt-contrib-copy')
grunt.loadNpmTasks('grunt-contrib-qunit')
grunt.loadNpmTasks('grunt-file-append')
grunt.registerTask('default', ['coffeelint', 'coffee:compile', 'copy:publish'])
grunt.registerTask('test', ['default', 'coffee:test', 'copy:test', 'file_append', 'connect', 'qunit'])