-
Notifications
You must be signed in to change notification settings - Fork 0
/
Gruntfile.js
109 lines (101 loc) · 2.49 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
/* global module:false, require:false */
var path = require('path');
var marked = require('marked');
var cheerio = require('cheerio');
var folderMount = function folderMount(connect, point) {
return connect.static(path.resolve(point));
};
marked.setOptions = {
smartypants : true
};
module.exports = function(grunt) {
grunt.registerTask('parseMd', 'parse Markdown files into template', function() {
var files = grunt.file.expand('text/*.md');
var raw, cooked, name;
var $ = cheerio.load(grunt.file.read('index.html'), {
xmlMode: false
});
for(var i=0,l=files.length;i<l;++i) {
name = path.basename(files[i], '.md');
raw = grunt.file.read(files[i]);
cooked = marked(raw);
$('#' + name).html(cooked);
}
grunt.file.write('index.html', $.html());
});
function registerRobustTasks(name, tasks) {
grunt.registerTask(name, function() {
// so we don't have stupid issues with grunt crashing
// every time a test fails...
grunt.option('force', true);
grunt.task.run(tasks);
});
}
grunt.initConfig({
pkg : grunt.file.readJSON('package.json'),
bower : {
install : {}
},
connect : {
server : {
options : {
base : '.',
port : 4949,
hostname : '*',
livereload : 4948
}
}
},
stylus : {
dev : {
options : {
// maybe later?
},
files : {
'css/style.css' : 'stylus/style.styl'
}
}
},
jshint : {
options : {
},
code : ['js/**/*.js', '!deps/**/*.js'],
all : ['js/**/*.js', '!js/deps/**/*.js']
},
watch : {
js : {
files : ['js/**/*.js',],
tasks : ['jshint:all'],
options : {
livereload : 4948
}
},
stylus : {
files : ['stylus/**/*.styl'],
tasks : ['stylus:dev'],
options : {
livereload : 4948
}
},
html : {
files : ['./**/*.html'],
options : {
livereload : 4948
}
},
md : {
files : ['./text/*.md'],
tasks : ['parseMd'],
options : {
livereload : 4948
}
}
}
});
grunt.loadNpmTasks('grunt-contrib-watch');
grunt.loadNpmTasks('grunt-contrib-connect');
grunt.loadNpmTasks('grunt-contrib-jshint');
grunt.loadNpmTasks('grunt-contrib-stylus');
grunt.loadNpmTasks('grunt-bower-task');
registerRobustTasks('default', ['connect', 'watch']);
};