forked from azukiapp/azk
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathGruntfile.js
135 lines (120 loc) · 2.95 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
'use strict';
function key_watch(grunt) {
var keypress = require('keypress');
var stdin = process.openStdin();
var touch = require('touch');
// make `process.stdin` begin emitting "keypress" events
keypress(process.stdin);
// listen for the "keypress" event
process.stdin.on('keypress', function (ch, key) {
if (key) {
if (key.ctrl && key.name == 'c') {
process.stdin.pause();
return process.exit();
} else if(key.name == "c") {
process.stdout.write('\u001B[2J\u001B[0;0f');
} else if(key.name == "r") {
// Reload
touch(__filename);
}
}
});
process.stdin.setRawMode(true);
process.stdin.resume();
}
module.exports = function(grunt) {
// Test options
var test_task = grunt.option('test') || "test";
var test_grep = grunt.option('grep') || null;
if (test_grep != null) {
test_task = "slow_test";
}
// Project configuration.
grunt.initConfig({
// ENV's
env: {
test: {
NODE_ENV: "test",
}
},
// Configuration to be run (and then tested).
traceur: {
options: {
sourceMaps: true,
modules: 'commonjs'
},
source: {
files: [{
expand: true,
cwd: 'src/',
src: ['**/*.js', '!share/*.js'],
dest: 'lib/azk/',
ext: '.js'
}]
},
spec: {
files: [{
expand: true,
cwd: 'spec/',
src: '**/*.js',
dest: 'lib/spec/',
ext: '.js'
}]
}
},
'node-inspector': {
dev: {}
},
mochaTest: {
test: {
options: {
reporter: 'spec',
timeout: 5000,
grep: "@slow",
invert: true,
},
src: ['lib/spec/**/*_spec.js']
},
slow_test: {
options: {
reporter: 'spec',
timeout: 50000,
grep: test_grep,
},
src: ['lib/spec/**/*_spec.js']
}
},
watch: {
spec: {
files: [
'Gruntfile.js',
'src/**/*.js',
'spec/**/*.js',
],
tasks: [test_task]
},
traceur: {
files: [
'Gruntfile.js',
'src/**/*.js',
'spec/**/*.js',
],
tasks: ['clear', 'newer:traceur']
}
},
});
// load all grunt tasks matching the `grunt-*` pattern
require('load-grunt-tasks')(grunt);
// Clear task
grunt.registerTask('clear', function() {
process.stdout.write('\u001B[2J\u001B[0;0f');
});
grunt.registerTask('test', ['env:test', 'clear', 'newer:traceur', 'mochaTest:test']);
grunt.registerTask('slow_test', ['env:test', 'clear', 'newer:traceur', 'mochaTest:slow_test']);
grunt.registerTask('compile', ['clear', 'newer:traceur', 'watch:traceur']);
grunt.registerTask('inspector', ["node-inspector"]);
grunt.registerTask('default', function() {
key_watch(grunt);
return grunt.task.run([test_task, 'watch:spec']);
});
};