-
Notifications
You must be signed in to change notification settings - Fork 0
/
Gruntfile.js
55 lines (41 loc) · 1.05 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
var path = require("path");
var glob = require("glob");
var _ = require("lodash");
var CLIENT_JS_PATH = path.resolve( __dirname, "./public/app/" );
var _clientJsCache;
module.exports = function( grunt ) {
grunt.initConfig({
pkg: grunt.file.readJSON('package.json'),
clientJs: _clientJSFiles(),
concat: {
js: {
src: '<%= clientJs %>',
dest: './public/rideasone.js'
}
}
});
grunt.loadNpmTasks('grunt-contrib-concat');
grunt.registerTask('default', ['compile-js']);
grunt.registerTask('compile-js', ['concat']);
};
function _moveAppJsToTop( files ){
var appjs = _.remove( files, function( file ){
return file === "app.js";
});
_.each( appjs, function( file ){
files.unshift( file );
});
return files;
}
function _clientJSFiles(){
if( _clientJsCache ) return _clientJsCache;
var options = {
cwd: CLIENT_JS_PATH
};
_clientJsCache = glob.sync( "**/*.js", options );
_moveAppJsToTop( _clientJsCache );
_clientJsCache = _.map(_clientJsCache, function(file) {
return CLIENT_JS_PATH + "/" + file;
});
return _clientJsCache;
};