forked from vitalets/checklist-model
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Gruntfile.js
116 lines (103 loc) · 2.48 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
module.exports = function(grunt) {
var fs = require('fs');
var extend = require('util')._extend;
grunt.util.linefeed = '\n';
//init configuration
grunt.config.init({
pkg: grunt.file.readJSON('package.json')
});
//clean
grunt.loadNpmTasks('grunt-contrib-clean');
grunt.config('clean', {
dist: 'dist'
});
//js hint
grunt.loadNpmTasks('grunt-contrib-jshint');
grunt.config('jshint', {
options: { },
all: [
'Gruntfile.js',
'checklist-model.js'
]
});
var banner = '/*!\n<%= pkg.name %> - <%= pkg.version %>\n' +
'<%= pkg.description %>\n'+
'Build date: <%= grunt.template.today("yyyy-mm-dd") %> \n*/\n';
//jade
var marked_ = require('marked');
var marked = function(text) {
var tok = marked_.lexer(text);
text = marked_.parser(tok);
// workaround to replace marked `<pre><code>` with '<pre class="prettyprint">'
text = text.replace(/<pre><code>(.*)<\/code><\/pre>/ig, '<pre class="prettyprint">$1</pre>');
return text;
};
var jadeData = {
fs: require('fs'),
md: marked,
version: '<%= pkg.version %>'
};
grunt.loadNpmTasks('grunt-contrib-jade');
grunt.config('jade', {
docs: {
options: {
pretty: true,
data: extend(extend({}, jadeData), {env: 'prod'})
},
files: [{src: 'docs/index.jade', dest: 'index.html'}]
}
/*
docsdev: {
options: {
pretty: true,
data: extend(extend({}, jadeData), {env: 'dev'})
},
files: [{src: 'docs/jade/main.jade', dest: 'dev.html'}]
}
*/
});
//connect
grunt.loadNpmTasks('grunt-contrib-connect');
grunt.config('connect', {
server: {
options: {
port: 8000,
base: '.'
}
}
});
//watch
grunt.loadNpmTasks('grunt-contrib-watch');
grunt.config('watch', {
jade: {
files: ['docs/**/*'],
tasks: ['jade'],
options: {
spawn: false
}
}
});
//bump
grunt.loadNpmTasks('grunt-bump');
grunt.config('bump', {
options: {
files: ['package.json', 'bower.json'],
updateConfigs: [],
commit: true,
commitMessage: 'bump %VERSION%',
commitFiles: ['package.json', 'bower.json'], // '-a' for all files
createTag: true,
tagName: '%VERSION%',
tagMessage: 'Version %VERSION%',
push: false
}
});
//metatasks
grunt.registerTask('docs', [
'jshint',
'jade'
]);
grunt.registerTask('server', [
'connect:server:keepalive'
]);
};