@ -1,4 +1,6 @@
module . exports = function ( grunt ) {
require ( 'time-grunt' ) ( grunt ) ;
var config = require ( './.credentials.json' ) ;
var branch = grunt . option ( 'branch' ) || config . branch ;
var email = grunt . option ( 'email' ) || config . email ;
@ -7,6 +9,14 @@ module.exports = function(grunt) {
grunt . loadNpmTasks ( 'grunt-screeps' ) ;
grunt . loadNpmTasks ( 'grunt-contrib-clean' ) ;
grunt . loadNpmTasks ( 'grunt-contrib-copy' ) ;
grunt . loadNpmTasks ( 'grunt-file-append' ) ;
var current _date = new Date ( ) ;
grunt . log . subhead ( 'Task start: ' + current _date . toLocaleString ( ) )
grunt . log . writeln ( 'Branch: ' + branch )
grunt . initConfig ( {
screeps : {
@ -19,6 +29,38 @@ module.exports = function(grunt) {
dist : {
src : [ 'dist/*.js' ]
}
} ,
clean : {
'dist' : [ 'dist' ]
} ,
copy : { // Copy all source files into the dist folder, flattening the folder structure
screeps : {
files : [ {
expand : true ,
cwd : 'src/' ,
src : '**' ,
dest : 'dist/' ,
filter : 'isFile' ,
rename : function ( dest , src ) {
return dest + src . replace ( /\//g , '_' ) ;
}
} ) ;
} ] ,
}
} ,
file _append : {
versioning : {
files : [
{
append : "\nglobal.SCRIPT_VERSION = " + current _date . getTime ( ) + "\n" ,
input : 'dist/version.js'
}
]
}
} ,
} )
grunt . registerTask ( 'default' , [ 'clean' , 'copy:screeps' , 'file_append:versioning' , 'screeps' ] ) ;
}