Skip to content

Commit

Permalink
logger: do not trim prefix (#231)
Browse files Browse the repository at this point in the history
  • Loading branch information
McAllaster committed Jun 16, 2020
1 parent 54b6456 commit e837544
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 1 deletion.
2 changes: 1 addition & 1 deletion src/logger.js
Expand Up @@ -53,7 +53,7 @@ module.exports = class Logger {
return _.reduce(prefixes, (prev, val, key) => {
const keyRegex = new RegExp(_.escapeRegExp(`{${key}}`), 'g');
return prev.replace(keyRegex, val);
}, prefix).trim();
}, prefix);
}

colorText(command, text) {
Expand Down
7 changes: 7 additions & 0 deletions src/logger.spec.js
Expand Up @@ -125,6 +125,13 @@ describe('#logCommandText()', () => {
expect(logger.log).toHaveBeenCalledWith(chalk.gray.dim('0-bar') + ' ', 'foo');
});

it('does not strip spaces from beginning or end of prefixFormat', () => {
const logger = createLogger({ prefixFormat: ' {index}-{name} ' });
logger.logCommandText('foo', { index: 0, name: 'bar' });

expect(logger.log).toHaveBeenCalledWith(chalk.gray.dim(' 0-bar ') + ' ', 'foo');
});

it('logs with no prefix', () => {
const logger = createLogger({ prefixFormat: 'none' });
logger.logCommandText('foo', { command: 'echo foo' });
Expand Down

0 comments on commit e837544

Please sign in to comment.