-
Notifications
You must be signed in to change notification settings - Fork 4
/
gruntfile.js
60 lines (55 loc) · 1.6 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
module.exports = function(grunt) {
var fs = require('fs');
var doc = {
options: {
destination: "docs/src",
access: ['public', 'undefined'],
format: "md",
version: "<%= pkg.version %>",
name: "<%= pkg.name %>",
filename: "MISC.md",
shallow: true
}
};
var watch = {
tests: {
files: ['test/*.js'],
tasks: ['shell:runTests']
}
};
/**
* scan files to generate documentation
*/
fs.readdirSync('./src/').forEach(function(file) {
if (file.substring(file.length - 3) === '.js') {
var key = file.substring(0, file.length - 3);
doc[key] = {
files: [{src: ['src/' + file]}],
options: {
filename: key.toUpperCase() + '.md'
}
}
watch[key] = {
files: ['src/' + file],
tasks: ['documentation:' + key, 'shell:runTests']
};
}
});
// Project configuration.
grunt.initConfig({
pkg: grunt.file.readJSON('package.json'),
documentation: doc,
watch: watch,
shell: {
runTests: {
command: 'clear && echo "\\n\\nrun tests\\n\\n" && npm run test'
}
}
});
grunt.loadNpmTasks('grunt-contrib-watch');
grunt.loadNpmTasks('grunt-documentation');
grunt.loadNpmTasks('grunt-shell');
// Default task(s).
grunt.registerTask('default', ['watch']);
grunt.registerTask('doc', ['documentation']);
};