-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathGruntfile.js
More file actions
98 lines (82 loc) · 2.15 KB
/
Gruntfile.js
File metadata and controls
98 lines (82 loc) · 2.15 KB
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
/* jshint node: true */
'use strict';
/*
This file was generated by generator-ffwd,
you probably should not modify it
*/
var fs = require('fs');
var path = require('path');
function loadConfig(options) {
options = options || {};
var files;
var name;
var loadableExp = /\.(json|js|node)$/;
var config = options.config || {};
var log = options.grunt ? options.grunt.log.writeln : console.log;
var error = options.grunt ? options.grunt.log.error : console.error;
try {
files = fs.readdirSync(path.resolve('./grunt/config'));
files.forEach(function(filename) {
if (loadableExp.test(filename)) {
name = filename.split('.').slice(0, -1).join('.');
var conf = require(path.resolve('./grunt/config/'+ filename));
if (typeof conf === 'function') {
conf = conf(options);
}
// log('Loaded configuration for '+ name);
config[name] = conf;
}
});
}
catch (err) {
error('Can not load '+ name +' configuration:\n'+ err.stack);
}
return config;
}
function loadTasks(grunt) {
var files;
var name;
var loadableExp = /\.(js|node)$/;
try {
files = fs.readdirSync(path.resolve('./grunt/tasks'));
files.forEach(function(filename) {
if (loadableExp.test(filename)) {
name = filename.split('.').slice(0, -1).join('.');
require(path.resolve('./grunt/tasks/'+ filename))(grunt);
}
});
}
catch (err) {
grunt.log.error('Can not load '+ name +' configuration:\n'+ err.stack);
}
}
module.exports = function (grunt) {
var pkg = require('./package.json');
grunt.pkg = pkg;
// Load grunt tasks automatically
require('load-grunt-tasks')(grunt);
// project tasks loading
loadTasks(grunt);
// Time how long tasks take. Can help when optimizing build times
require('time-grunt')(grunt);
var config = loadConfig({
config: {
pkg: pkg
},
grunt: grunt
});
grunt.initConfig(config);
grunt.registerTask('develop', [
'build:dev',
'express:dev',
'watch'
]);
grunt.registerTask('default', [
'build'
]);
grunt.registerTask('serve', [
'build',
'express:prod',
'express-keepalive'
]);
};