-
Notifications
You must be signed in to change notification settings - Fork 44
/
Gruntfile.js
120 lines (114 loc) · 3.08 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
117
118
119
120
module.exports = function(grunt) {
grunt.initConfig({
concurrent: {
dev: {
tasks: ['nodemon', 'watch'],
options: {
logConcurrentOutput: true
}
}
},
nodemon: {
dev: {
script: 'index.js',
options: {
ext: 'js,css,html,tpl',
watch: ['**/*.js', '**/*.tpl', '**/*.css', 'public/index.html', '**/*.json'],
nodeArgs: ['--debug'],
env: {
PORT: '8080'
},
// omit this property if you aren't serving HTML files and
// don't want to open a browser tab on start
callback: function(nodemon) {
nodemon.on('log', function(event) {
console.log(event.colour);
});
// opens browser on initial server start
nodemon.on('config:update', function() {
// Delay before server listens on port
setTimeout(function() {
require('open')('http://localhost:8080');
}, 1000);
});
// refreshes browser when server reboots
nodemon.on('restart', function() {
// Delay before server listens on port
setTimeout(function() {
require('fs').writeFileSync('.rebooted', 'rebooted');
}, 3000);
});
}
}
}
},
watch: {
server: {
files: ['.rebooted'],
options: {
livereload: true,
debounceDelay: 500
}
},
javascript: {
files: ['includes/**/*.js'],
tasks: "test"
}
},
env: {
options: {},
test: {
NODE_ENV: 'test'
},
apiary: {
APIARY_API_KEY: process.env.DIMESHIFT_APIARY_API_KEY // https://login.apiary.io/tokens
}
},
concat: {
options: {
separator: '\n \n',
},
dist: {
src: ["docs/api.md", "includes/routes/**/*.apib"],
dest: 'data/cache/api.apib'
}
},
exec: {
publish: ['apiary', 'publish', ['--api-name', 'dimeshift'].join('='), ['--path', 'data/cache/api.apib'].join('=')].join(' ')
},
run: {
test_server: {
options: {
wait: false
},
args: [
'index.js'
]
}
},
mochacli: {
options: {
require: [],
reporter: 'spec',
bail: true,
sort: true,
env: {
NODE_ENV: 'test'
}
},
all: ['includes/test/*.js']
}
});
grunt.loadNpmTasks('grunt-contrib-watch');
grunt.loadNpmTasks('grunt-nodemon');
grunt.loadNpmTasks('grunt-concurrent');
grunt.loadNpmTasks('grunt-mocha-cli');
grunt.loadNpmTasks('grunt-env');
grunt.loadNpmTasks('grunt-run');
grunt.loadNpmTasks('grunt-exec');
grunt.loadNpmTasks('grunt-contrib-concat');
grunt.registerTask('default', ['concurrent']);
grunt.registerTask('dev', ['concurrent']);
grunt.registerTask('test', ['env:test', 'run:test_server', 'mochacli', 'stop:test_server']);
grunt.registerTask('apiary', ['env:apiary', 'concat', 'exec:publish']);
};