forked from franciscop/umbrella
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Gruntfile.js
98 lines (80 loc) · 2.53 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
fs = require('fs');
// This builds the library itself
module.exports = function (grunt) {
// Configuration
grunt.initConfig({
pkg: grunt.file.readJSON('package.json'),
uglify: {
options: { banner: '/* Umbrella JS ' + require('./package').version + ' umbrellajs.com */\n'},
build: { src: 'umbrella.js', dest: 'umbrella.min.js' }
},
watch: {
scripts: {
files: [
'package.js', // To bump versions
'Gruntfile.js',
'src/*.js',
'src/*.md',
'src/plugins/*.js',
'src/plugins/*.md',
'src/plugins/*/*.js',
'src/plugins/*/*.md',
'web/*.jade',
'web/*'
],
tasks: ['default'],
options: { spawn: false, },
}
},
jade: {
compile: {
options: {
client: false
},
files: [ {
cwd: "web",
src: "**/*.html.jade",
dest: ".",
expand: true,
ext: ".html"
} ]
}
},
mocha_phantomjs: {
all: './tests.html'
}
});
// Dynamically add plugins to the concat
// Order of include is irrelevant http://stackoverflow.com/q/7609276
grunt.registerTask("parse", "Join and concatenate", function(){
// get the current concat config
var concat = {
main: { src: [ 'src/umbrella.js' ], dest: 'umbrella.js' },
test: { src: [ 'src/test.js' ], dest: 'test/test.js' },
docs: { src: [ 'src/documentation.md' ], dest: 'documentation.md' }
};
fs.readdirSync(__dirname + "/src/plugins").forEach(function(name, i){
var file = 'src/plugins/' + name + '/' + name + '.js';
var test = 'src/plugins/' + name + '/test.js';
var doc = 'src/plugins/' + name + '/documentation.md';
if (!fs.existsSync(file)) throw new Error("File '" + file + "' doesn't exist");
concat.main.src.push(file);
concat.test.src.push(test);
concat.docs.src.push(doc);
});
// save the new concat configuration
grunt.config.set('concat', concat);
});
// Concatenate
grunt.loadNpmTasks('grunt-contrib-concat');
// Minify
grunt.loadNpmTasks('grunt-contrib-uglify');
// Watch
grunt.loadNpmTasks('grunt-contrib-watch');
// Jade
grunt.loadNpmTasks('grunt-contrib-jade');
// Testing
grunt.loadNpmTasks('grunt-mocha-phantomjs');
// 4. Where we tell Grunt what to do when we type "grunt" into the terminal
grunt.registerTask('default', ['parse', 'concat', 'uglify', 'jade', 'mocha_phantomjs']);
};