diff --git a/index.js b/index.js index 9a4ab34..a9d9722 100644 --- a/index.js +++ b/index.js @@ -3,10 +3,10 @@ Initial code from https://github.com/gulpjs/gulp-util/blob/v3.0.6/lib/log.js */ var chalk = require('chalk'); -var dateformat = require('dateformat'); +var timestamp = require('time-stamp'); function getTimestamp(){ - return '['+chalk.grey(dateformat(new Date(), 'HH:MM:ss'))+']'; + return '['+chalk.grey(timestamp('HH:mm:ss'))+']'; } function log(){ diff --git a/package.json b/package.json index b97620a..8ab4ef9 100644 --- a/package.json +++ b/package.json @@ -19,7 +19,7 @@ }, "dependencies": { "chalk": "^1.1.1", - "dateformat": "^1.0.11" + "time-stamp": "^1.0.0" }, "devDependencies": { "@phated/eslint-config-iceddev": "^0.2.1", diff --git a/test.js b/test.js index c56047f..ce73d64 100644 --- a/test.js +++ b/test.js @@ -5,7 +5,7 @@ var lab = exports.lab = require('lab').script(); var code = require('code'); var chalk = require('chalk'); -var dateformat = require('dateformat'); +var timestamp = require('time-stamp'); var log = require('./'); @@ -28,7 +28,7 @@ lab.describe('log()', function(){ process.stdout.write = writeSpy; log(1, 2, 3, 4, 'five'); - var time = dateformat(new Date(), 'HH:MM:ss'); + var time = timestamp('HH:mm:ss'); code.expect(writtenValue).equals('[' + chalk.grey(time) + '] 1 2 3 4 \'five\'\n'); // Restore process.stdout.write after test @@ -42,7 +42,7 @@ lab.describe('log()', function(){ process.stdout.write = writeSpy; log('%s %d %j', 'something', 0.1, {key: 'value'}); - var time = dateformat(new Date(), 'HH:MM:ss'); + var time = timestamp('HH:mm:ss'); code.expect(writtenValue).equals( '[' + chalk.grey(time) + '] '+ 'something 0.1 {\"key\":\"value\"}\n' @@ -74,7 +74,7 @@ lab.describe('log.error()', function(){ process.stderr.write = writeSpy; log.error(1, 2, 3, 4, 'five'); - var time = dateformat(new Date(), 'HH:MM:ss'); + var time = timestamp('HH:mm:ss'); code.expect(writtenValue).equals('[' + chalk.grey(time) + '] 1 2 3 4 \'five\'\n'); // Restore process.stderr.write after test @@ -88,7 +88,7 @@ lab.describe('log.error()', function(){ process.stderr.write = writeSpy; log.error('%s %d %j', 'something', 0.1, {key: 'value'}); - var time = dateformat(new Date(), 'HH:MM:ss'); + var time = timestamp('HH:mm:ss'); code.expect(writtenValue).equals( '[' + chalk.grey(time) + '] '+ 'something 0.1 {\"key\":\"value\"}\n'