-
Notifications
You must be signed in to change notification settings - Fork 23
/
Gruntfile.js
176 lines (165 loc) · 4.02 KB
/
Gruntfile.js
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
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
module.exports = function(grunt) {
require('grunt-task-loader')(grunt);
grunt.initConfig({
starlight: {
test: {
src: 'test/lua/**/*.lua',
dest: 'dist/test/test.lua.js',
options: {
main: 'test-runner.lua',
basePath: 'test/lua'
}
}
},
concat: {
'browser-lib': {
src: [
'dist/browser/runtime.js',
'src/DOMAPI/DOMAPI.js',
'dist/browser/parser.js'
],
dest: 'dist/browser-lib/starlight.js'
}
},
uglify: {
test: {
src: 'dist/test/test.lua.js',
dest: 'dist/test/test.lua.js'
},
runtime: {
src: 'dist/browser/runtime.js',
dest: 'dist/browser/runtime.js'
},
parser: {
src: 'dist/browser/parser.js',
dest: 'dist/browser/parser.js'
},
babel: {
src: 'node_modules/babel/node_modules/babel-core/browser.min.js',
dest: 'dist/browser/babel.js'
},
'browser-lib': {
src: 'dist/browser-lib/starlight.js',
dest: 'dist/browser-lib/starlight.js'
}
},
babel: {
'grunt-plugin-common': {
files: [
{
expand: true,
src: ['*.js'],
cwd: 'src/build-tools/common/',
dest: 'dist/build-tools/grunt-starlight/lib/',
ext: '.js'
}
]
},
runtime: {
files: [
{
expand: true,
src: ['**/*.js'],
cwd: 'src/runtime/',
dest: 'dist/node/',
ext: '.js'
}
]
},
test: {
src: 'dist/test/test.lua.js',
dest: 'dist/test/test.lua.js'
},
parser: {
files: [
{
expand: true,
src: ['index.js'],
cwd: 'src/parser/',
dest: 'dist/node/parser/',
ext: '.js'
}
]
},
'parser-codegen': {
files: [
{
expand: true,
src: ['*.js'],
cwd: 'src/build-tools/common/',
dest: 'dist/node/parser/',
ext: '.js'
}
]
},
},
copy: {
'grunt-plugin': {
files: [
{
expand: true,
src: ['**/*'],
cwd: 'src/build-tools/grunt/',
dest: 'dist/build-tools/grunt-starlight/'
}
],
},
'grunt-plugin-module': {
files: [
{
expand: true,
src: ['**/*'],
cwd: 'dist/build-tools/grunt-starlight/',
dest: 'node_modules/grunt-starlight/'
}
],
},
test: {
src: 'test/index.html',
dest: 'dist/test/index.html'
},
'browser-lib': {
files: {
'dist/browser-lib/index.html': 'src/browser-lib/index.html',
'dist/browser-lib/README.md': 'src/browser-lib/README.md'
}
}
},
browserify: {
runtime: {
files: {
'dist/browser/runtime.js': ['dist/node/index.js'],
}
},
test: {
files: {
'dist/test/test.lua.js': ['dist/test/test.lua.js'],
}
},
parser: {
files: {
'dist/browser/parser.js': ['dist/node/parser/index.js'],
}
}
}
});
grunt.registerTask('grunt-plugin', ['copy:grunt-plugin', 'babel:grunt-plugin-common', 'copy:grunt-plugin-module']);
grunt.registerTask('runtime', ['babel:runtime', 'browserify:runtime', 'uglify:runtime']);
grunt.registerTask('test', ['starlight:test', 'babel:test', 'browserify:test', 'uglify:test', 'copy:test']);
grunt.registerTask('parser', ['babel:parser', 'babel:parser-codegen', 'browserify:parser', 'uglify:parser', 'uglify:babel']);
grunt.registerTask('browser-lib', ['babel:runtime', 'browserify:runtime', 'babel:parser', 'babel:parser-codegen', 'browserify:parser', 'concat:browser-lib', 'uglify:browser-lib', 'copy:browser-lib']);
grunt.registerTask('node-test', ['babel:parser', 'babel:parser-codegen', 'babel:runtime', 'starlight:test', 'babel:test', 'run-test']);
grunt.registerTask('run-test', function () {
global.babel = {
transform: require('./node_modules/babel').transform
};
global.starlight = { config: { env: {
getTimestamp: Date.now.bind(Date),
inspect: console.log.bind(console)
} } };
require('./dist/node/parser/index.js');
require('./dist/node/index.js');
require('./dist/test/test.lua.js');
})
grunt.registerTask('default', ['runtime', 'babel:parser', 'babel:parser-codegen', 'test', 'run-test']);
};