-
Notifications
You must be signed in to change notification settings - Fork 1
/
Gruntfile.js
75 lines (69 loc) · 1.69 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
var fs = require('fs'),
path = require('path');
// Removes a directory if it exists.
// Throws an exception if deletion fails.
function removeDir(dir) {
if (fs.existsSync(dir) && fs.statSync(dir).isDirectory()) {
// Delete its contents, since you can't delete non-empty folders.
// :(
var files = fs.readdirSync(dir);
for (var i = 0; i < files.length; i++) {
var fname = dir + path.sep + files[i];
if (fs.statSync(fname).isDirectory()) {
removeDir(fname);
} else {
removeFile(fname);
}
}
fs.rmdirSync(dir);
}
}
// Removes a file if it exists.
// Throws an exception if deletion fails.
function removeFile(file) {
if (fs.existsSync(file) && fs.statSync(file).isFile()) {
fs.unlinkSync(file);
}
}
module.exports = function(grunt) {
grunt.initConfig({
// Metadata.
pkg: grunt.file.readJSON('package.json'),
ts: {
options: {
sourcemap: true,
module: 'commonjs',
comments: true
},
release: {
src: ["ar.ts"],
outDir: 'lib',
options: {
declaration: true
}
},
test: {
// In-place compilation
src: ["tests/runner.ts"],
}
},
shell: {
test: {
options: {
stdout: true
},
command: 'node tests/runner.js'
}
}
});
grunt.loadNpmTasks('grunt-ts');
grunt.loadNpmTasks('grunt-shell');
grunt.registerTask('clean', 'Removes all built files.', function() {
removeDir('./lib');
removeFile('./tests/runner.js');
});
// release build (default)
grunt.registerTask('default', ['ts:release']);
// test
grunt.registerTask('test', ['ts:test', 'shell:test']);
};