-
-
Notifications
You must be signed in to change notification settings - Fork 229
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Added support for string interpolation. Fixes #20 #23
Changes from 3 commits
5731fa2
e244713
50755f5
d384e37
4bee762
bb02846
9e1cac7
cdbf135
fe8c7cb
5b6b670
721a146
664013b
938daa0
37a7fc1
ffaa379
55f58df
e7252da
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,5 @@ | ||
'use strict'; | ||
const util = require('util'); | ||
const path = require('path'); | ||
const chalk = require('chalk'); | ||
const figures = require('figures'); | ||
|
@@ -131,14 +132,14 @@ class Signale { | |
|
||
if (args.length === 1 && typeof (args[0]) === 'object' && args[0] !== null) { | ||
if (args[0] instanceof Error) { | ||
[msg] = args; | ||
[msg] = args; // See this github issue comment (https://github.com/nodejs/node/issues/9406#issuecomment-257724625) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
|
||
} else { | ||
const [{prefix, message, suffix}] = args; | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Here There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I have removed signale.success({a: 2});
signale.success([1, 2]); Can you give some use cases so tat i can check that. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Looks nice! The only thing left is to bring back const [{prefix, message, suffix}] = args; and directly apply interpolation on it: msg = util.format(...message); Thank you a lot for taking the time to help out : ) There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Yes, that I have to do. I am getting There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Yep, it is only applicable when using the const signale = require('signale');
signale.complete({prefix: '[task]', message: ['Fix issue #%s', 59], suffix: '(@santa)'});
//=> [task] ☒ complete Fix issue #59 (@santa) There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. now I have to check undefined case. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Done. |
||
msg = message; | ||
const [{prefix, suffix}] = args; | ||
msg = util.format(util.inspect(...args)); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The same can be done here: msg = util.format(...message); |
||
additional = Object.assign({}, {suffix, prefix}); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Just a minor reordering of the assignments: const [{prefix, message, suffix}] = args;
additional = Object.assign({}, {suffix, prefix});
msg = message ? util.format(...message) : this._hasAdditional(additional, args); There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. It's better than my previous method |
||
} | ||
} else { | ||
msg = args.join(' '); | ||
msg = util.format(args[0], ...args.slice(1, args.length)); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. To simplify it even more, the msg = util.format(...args); |
||
} | ||
|
||
const signale = this._meta(); | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This one should be removed since it is not part of the default developing environment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
That's my fault. I am removing this.