-
Notifications
You must be signed in to change notification settings - Fork 939
Expand file tree
/
Copy pathcompile.js
More file actions
34 lines (29 loc) · 787 Bytes
/
compile.js
File metadata and controls
34 lines (29 loc) · 787 Bytes
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
"use strict";
module.exports = function( grunt ) {
grunt.registerMultiTask(
"compile",
"Compile sizzle.js to the dist directory. Embed date/version.",
function() {
var data = this.data,
dest = data.dest,
src = data.src,
version = grunt.config( "pkg.version" ),
compiled = grunt.file.read( src );
// Embed version and date
compiled = compiled
.replace( /@VERSION/g, version )
.replace( "@DATE", function() {
var date = new Date();
// YYYY-MM-DD
return [
date.getFullYear(),
( "0" + ( date.getMonth() + 1 ) ).slice( -2 ),
( "0" + date.getDate() ).slice( -2 )
].join( "-" );
} );
// Write source to file
grunt.file.write( dest, compiled );
grunt.log.ok( "File written to " + dest );
}
);
};