add builtAt stats option. use locale string functions

This commit is contained in:
Connor Clark 2018-01-30 17:34:08 -08:00
parent 152575c2b0
commit 5266a30808
12 changed files with 22 additions and 4 deletions

View File

@ -105,6 +105,7 @@ class Stats {
const showEnv = optionOrLocalFallback(options.env, false);
const showVersion = optionOrLocalFallback(options.version, true);
const showTimings = optionOrLocalFallback(options.timings, true);
const showBuiltAt = optionOrLocalFallback(options.builtAt, true);
const showAssets = optionOrLocalFallback(options.assets, true);
const showEntrypoints = optionOrLocalFallback(options.entrypoints, true);
const showChunks = optionOrLocalFallback(options.chunks, !forToString);
@ -252,6 +253,9 @@ class Stats {
if(showHash) obj.hash = this.hash;
if(showTimings && this.startTime && this.endTime) {
obj.time = this.endTime - this.startTime;
}
if(showBuiltAt && this.endTime) {
obj.builtAt = this.endTime;
}
@ -618,11 +622,11 @@ class Stats {
newline();
}
if(typeof obj.builtAt === "number") {
const now = (new Date(obj.builtAt)).toString().split(" ");
const builtAtDate = new Date(obj.builtAt);
colors.normal("Built at: ");
colors.normal(`${now[0]} ${now[1]} ${now[2]} ${now[3]} `);
colors.bold(now[4]);
colors.normal(now[6] ? ` ${now[5]} ${now[6]}` : ` ${now[5]}`);
colors.normal(builtAtDate.toLocaleDateString());
colors.normal(" ");
colors.bold(builtAtDate.toLocaleTimeString());
newline();
}
if(obj.env) {

View File

@ -1655,6 +1655,10 @@
"type": "boolean",
"description": "add timing information"
},
"builtAt": {
"type": "boolean",
"description": "add built at time information"
},
"performance": {
"type": "boolean",
"description": "add performance hint flags"

View File

@ -2,6 +2,7 @@ const path = require("path");
const stats = {
hash: false,
timings: false,
builtAt: false,
assets: false,
chunks: true,
chunkOrigins: true,

View File

@ -9,6 +9,7 @@ module.exports = {
stats: {
hash: false,
timings: false,
builtAt: false,
assets: false,
chunks: true,
chunkOrigins: true,

View File

@ -7,6 +7,7 @@ module.exports = {
stats: {
hash: false,
timings: false,
builtAt: false,
assets: false,
chunks: true,
chunkModules: true,

View File

@ -10,6 +10,7 @@ module.exports = {
stats: {
hash: false,
timings: false,
builtAt: false,
assets: false,
chunks: true,
chunkModules: true,

View File

@ -10,6 +10,7 @@ module.exports = {
stats: {
hash: false,
timings: false,
builtAt: false,
assets: false,
chunks: true,
chunkModules: true,

View File

@ -11,6 +11,7 @@ module.exports = {
stats: {
hash: false,
timings: false,
builtAt: false,
chunks: true,
chunkModules: true,
modules: false

View File

@ -11,6 +11,7 @@ module.exports = {
stats: {
hash: false,
timings: false,
builtAt: false,
chunks: true,
chunkModules: true,
modules: false

View File

@ -5,6 +5,7 @@ module.exports = {
entry: "./index",
stats: {
timings: false,
builtAt: false,
hash: false,
modules: true,
chunks: false

View File

@ -22,6 +22,7 @@ module.exports = [
entrypoints: true,
hash: false,
timings: false,
builtAt: false,
chunks: false,
assets: false
}

View File

@ -1,6 +1,7 @@
const stats = {
hash: false,
timings: false,
builtAt: false,
assets: false,
chunks: true,
chunkOrigins: true,