-
Notifications
You must be signed in to change notification settings - Fork 7
/
Copy pathGruntfile.js
109 lines (95 loc) · 2.36 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
module.exports = function(grunt) {
var path = require('path'),
fs = require('fs'),
shell = require('shelljs');
grunt.loadNpmTasks('grunt-docco');
// Load grunt tasks automatically
require('load-grunt-tasks')(grunt);
var MODULE_NAME = 'tz-date';
var SRC_DIR = 'src';
var DIST_DIR = 'lib';
var DOCS_DIR = 'docs';
// Define the configuration for all the tasks.
grunt.initConfig({
coffee: {
dist: {
expand: true,
flatten: false,
cwd: SRC_DIR,
src: ['**/*.coffee'],
dest: DIST_DIR,
ext: '.js'
}
},
copy: {
dist: {
expand: true,
cwd: SRC_DIR,
src: ['fixtures/**/*'],
dest: DIST_DIR
}
},
clean: {
dist: DIST_DIR,
docs: DOCS_DIR
},
docco: {
debug: {
src: ['src/**/*.coffee'],
options: {
output: DOCS_DIR
}
}
},
mochaTest: {
test: {
options: {
reporter: 'spec',
require: 'coffee-script/register'
},
src: ['test/**/*Spec.coffee']
}
},
'node-inspector': {
dev: {
options: {
'hidden': ['node_modules']
}
}
}
});
grunt.registerTask('build', 'Build a distributable package.', ['coffee:dist', 'copy:dist']);
grunt.registerTask('test', 'Runs tests.', function (arg1) {
if (arg1 === undefined) {
grunt.task.run('mochaTest');
} else {
shell.exec('mocha --reporter spec --require coffee-script/register test/' + arg1);
}
});
grunt.registerTask('docs', 'Compiles docs with Docco.', function() {
grunt.task.run('docco');
});
grunt.registerTask('inspector', 'Runs node-inspector.', ['node-inspector:dev']);
grunt.registerTask('test:ci', 'Runs tests.', ['mochaTest']);
// FILES
function readFile(file) {
return fs.readFileSync(file, {encoding: 'utf-8'});
}
function writeFile(file, data) {
if (typeof data === 'function') {
data = data(readFile(file));
}
fs.writeFileSync(file, data);
}
function _prefixPath(dir, args) {
var prefixedArgs = Array.prototype.slice.apply(args);
prefixedArgs.unshift(dir);
return path.join.apply(path, prefixedArgs);
}
function srcPath() {
return _prefixPath(SRC_DIR, arguments);
}
function distPath() {
return _prefixPath(DIST_DIR, arguments);
}
};