Created
September 13, 2016 08:00
-
-
Save DannyFeliz/ec987793de2b97e92a6fa629695a40dd to your computer and use it in GitHub Desktop.
Add timestamp to webpack
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/** | |
* Get current time | |
* @example 10:34:12 am | |
* @param {Date} date | |
* @returns {string} | |
*/ | |
function getTime(date) { | |
var hours = date.getHours(); | |
var minutes = date.getMinutes(); | |
var seconds = date.getSeconds(); | |
var ampm = hours >= 12 ? 'pm' : 'am'; | |
hours = hours % 12; | |
hours = hours ? hours : 12; // the hour '0' should be '12' | |
minutes = minutes < 10 ? '0' + minutes : minutes; | |
seconds = seconds < 10 ? '0' + seconds : seconds; | |
return hours + ':' + minutes + ':' + seconds + " " + ampm; | |
} | |
/** | |
* Get current date | |
* @example 13-09-2016 | |
* @returns {string} | |
*/ | |
function getDate() { | |
var currentDate = new Date(); | |
return getTime(currentDate) + " - " +("0" + currentDate.getDate()).slice(-2) + "-" + ("0"+(currentDate.getMonth()+1)).slice(-2) + "-" + | |
currentDate.getFullYear(); | |
} | |
plugins: [ | |
function () { | |
this.plugin('compile', function () { | |
console.log('Start: ' + getDate().red); | |
}) | |
}, | |
function () { | |
this.plugin('done', function () { | |
console.log('End: ' + getDate().yellow ); | |
}) | |
}, | |
] |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment