This repository has been archived by the owner on Apr 6, 2019. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Gruntfile.js
63 lines (60 loc) · 1.5 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
var path = require('path'),
mg = require('mongoose'),
credentials = require('./config/credentials'),
Admin = require('./app/models/admin')
module.exports = function(grunt) {
grunt.initConfig({
pkg: grunt.file.readJSON('package.json'),
/* 编译客户端使用模板 */
jade: {
compile: {
options: {
client: true,
namespace: 'Template',
processName: function(filename) {
return path.basename(filename, path.extname(filename))
},
},
files: {
'public/js/templates.js': 'app/views/client/*.jade',
},
},
},
watch: {
options: {
reload: true,
},
jade: {
files: 'app/views/client/*.jade',
tasks: 'jade',
},
},
})
//初始化管理账户
grunt.registerTask('initdb', '创建初始管理员', function(env) {
env = env || 'development'
var connectString = credentials.mongo[env].connectString,
done = this.async()
mg.connect(connectString)
new Admin({
name: 'root',
card_no: '0000',
password: '0000',
role: 'super',
})
.save()
.then(function(data) {
if (data) {
grunt.log.writeln('创建成功')
done()
}
})
.catch(function(err) {
grunt.log.writeln('创建失败', err)
done()
})
})
grunt.loadNpmTasks('grunt-contrib-jade')
grunt.loadNpmTasks('grunt-contrib-watch')
grunt.registerTask('default', ['jade'])
}