Skip to content

Commit

Permalink
Update: Replace dateformat module with time-stamp
Browse files Browse the repository at this point in the history
  • Loading branch information
jonschlinkert authored and phated committed Nov 29, 2018
1 parent 788309d commit 995b2c1
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 8 deletions.
4 changes: 2 additions & 2 deletions index.js
Original file line number Diff line number Diff line change
Expand Up @@ -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(){
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down
10 changes: 5 additions & 5 deletions test.js
Original file line number Diff line number Diff line change
Expand Up @@ -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('./');

Expand All @@ -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
Expand All @@ -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'
Expand Down Expand Up @@ -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
Expand All @@ -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'
Expand Down

0 comments on commit 995b2c1

Please sign in to comment.