Skip to content

Commit

Permalink
feat(exposed/tags): adds log
Browse files Browse the repository at this point in the history
  • Loading branch information
rafamel committed Apr 26, 2019
1 parent aba9763 commit c9b3a1c
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 0 deletions.
1 change: 1 addition & 0 deletions src/exposed/tags/index.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
export { default as ensure } from './ensure';
export { default as exists } from './exists';
export { default as line } from './line';
export { default as log } from './log';
export { default as rm } from './rm';
export { default as silent } from './silent';
18 changes: 18 additions & 0 deletions src/exposed/tags/log.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
import { TScript } from '~/types';
import asTag from '~/utils/as-tag';

export default log;

function log(message: string): TScript;
function log(literals: TemplateStringsArray, ...placeholders: any[]): TScript;
/**
* String tag; logs a string on `stdout`.
* @returns A `TScript`, as a function, that won't be executed until called by `kpo` -hence, calling `log` won't have any effect until the returned function is called.
*/
function log(...args: any[]): TScript {
return function log(): void {
const message = asTag(args.shift(), ...args);
// eslint-disable-next-line no-console
console.log(message);
};
}

0 comments on commit c9b3a1c

Please sign in to comment.