Skip to content
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

Merged
merged 17 commits into from
Jun 9, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -12,4 +12,4 @@ yarn.lock
.vscode
.idea
*.swp
*.swo
*.swo
9 changes: 7 additions & 2 deletions signale.js
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');
Expand Down Expand Up @@ -154,6 +155,10 @@ class Signale {
return meta;
}

_hasAdditional({suffix, prefix}, args) {
return (suffix || prefix) ? '' : util.format(...args);
}

_buildSignale(type, ...args) {
let [msg, additional] = [{}, {}];

Expand All @@ -162,11 +167,11 @@ class Signale {
[msg] = args;
} else {
const [{prefix, message, suffix}] = args;
msg = message;
additional = Object.assign({}, {suffix, prefix});
msg = message ? util.format(...message) : this._hasAdditional(additional, args);
}
} else {
msg = args.join(' ');
msg = util.format(...args);
}

const signale = this._meta();
Expand Down