add build date

This commit is contained in:
rozbo 2016-06-22 19:15:47 +08:00
parent 95c7f6daa0
commit 76b0dcae08
2 changed files with 20 additions and 9 deletions

View File

@ -28,6 +28,12 @@ function logic_html(str, data) {
var result = Htmlminifier(str, options); var result = Htmlminifier(str, options);
var saved = ((str.length - result.length) / str.length * 100).toFixed(2); var saved = ((str.length - result.length) / str.length * 100).toFixed(2);
log.log('neat the html: %s [ %s saved]', path, saved + '%'); log.log('neat the html: %s [ %s saved]', path, saved + '%');
var now = new Date();
// var prefix='<!-- build time:'+ now.getFullYear() +"年"+(now.getMonth() + 1)+"月"+now.getDate()+"日"
// +now.getHours()+":"+now.getMinutes()+":"
var prefix = '<!-- build time:' + now.toLocaleString() + " -->";
var end = '<!-- rebuild by neat -->';
result = prefix + result + end;
return result; return result;
}; };
@ -52,7 +58,10 @@ function logic_css(str, data) {
new CleanCSS(options).minify(str, function(err, result) { new CleanCSS(options).minify(str, function(err, result) {
if (err) return reject(err); if (err) return reject(err);
var saved = ((str.length - result.styles.length) / str.length * 100).toFixed(2); var saved = ((str.length - result.styles.length) / str.length * 100).toFixed(2);
resolve(result.styles); var prefix = '/* build time:' + new Date().toLocaleString() + "*/\n";
var end = '\n/* rebuild by neat */';
var css_result = prefix + result.styles + end;
resolve(css_result);
log.log('neat the css: %s [ %s saved]', path, saved + '%'); log.log('neat the css: %s [ %s saved]', path, saved + '%');
}); });
}); });
@ -78,8 +87,10 @@ function logic_js(str, data) {
var result = UglifyJS.minify(str, options); var result = UglifyJS.minify(str, options);
var saved = ((str.length - result.code.length) / str.length * 100).toFixed(2); var saved = ((str.length - result.code.length) / str.length * 100).toFixed(2);
log.log('neat the js: %s [ %s saved]', path, saved + '%'); log.log('neat the js: %s [ %s saved]', path, saved + '%');
var prefix = '// build time:' + new Date().toLocaleString() + "\n";
return result.code; var end = '\n//rebuild by neat ';
var js_result = prefix + result.code + end;
return js_result;
} }

View File

@ -33,5 +33,5 @@
"scripts": { "scripts": {
"test": "echo \"Error: no test specified\" && exit 1" "test": "echo \"Error: no test specified\" && exit 1"
}, },
"version": "1.0.2" "version": "1.0.3"
} }