forked from getoutreach/adminjs
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Gruntfile.js
93 lines (74 loc) · 3.11 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
module.exports = function(grunt) {
var config = {
pkg: grunt.file.readJSON('package.json'),
env: process.env,
clean: ['tmp']
};
grunt.util._.extend(config, loadConfig('./tasks/options/'));
grunt.initConfig(config);
grunt.registerMultiTask('browser', "Export a module to the window", function() {
var opts = this.options();
this.files.forEach(function(f) {
var output = ["(function(globals) {"];
output.push.apply(output, f.src.map(grunt.file.read));
output.push(grunt.template.process(
'window.<%= namespace %> = requireModule("<%= barename %>");', {
data: {
namespace: opts.namespace,
barename: opts.barename
}
}));
output.push('})(window);');
grunt.file.write(f.dest, grunt.template.process(output.join("\n")));
});
});
require('matchdep').filterDev('grunt-*').forEach(grunt.loadNpmTasks);
grunt.loadTasks('tasks');
grunt.registerTask('default', "Build (in debug mode) & test your application.", ['build:debug', 'test']);
grunt.registerTask('build', [
'lock',
'clean',
'copy:prepare',
'transpile',
'jshint',
'copy:stage',
'emberTemplates',
'stylus',
'emblem',
'concat',
'browser',
'unlock' ]);
grunt.registerTask('build:debug', "Build a development-friendly version of your app.", [
'build',
'copy:vendor',
'copy:dist' ]);
grunt.registerTask('build:prod', "Build a minified & production-ready version of your app.", [
'useminPrepare',
'build',
'uglify',
'rev',
'usemin' ]);
grunt.registerTask('test', "Run your apps's tests once. Uses Google Chrome by default. Logs coverage output to tmp/public/coverage.", [
'karma:test' ]);
grunt.registerTask('test:ci', "Run your app's tests in PhantomJS. For use in continuous integration (i.e. Travis CI).", [
'karma:ci' ]);
grunt.registerTask('test:server', "Start a Karma test server. Automatically reruns your tests when files change and logs the results to the terminal.", [
'build:debug', 'karma:server', 'connect', 'watch:test']);
grunt.registerTask('server', "Run your server in development mode, auto-rebuilding when files change.",
['build:debug', 'connect', 'watch:main']);
grunt.registerTask('server:dist', "Preview production (minified) assets.",
['build:prod', 'connect:server:keepalive']);
};
// TODO: extract this out
function loadConfig(path) {
var string = require('string');
var glob = require('glob');
var object = {};
var key;
glob.sync('*', {cwd: path}).forEach(function(option) {
key = option.replace(/\.js$/,'');
key = string(key).camelize().s;
object[key] = require(path + option);
});
return object;
}