Skip to content

Commit

Permalink
🚧 updated logger
Browse files Browse the repository at this point in the history
  • Loading branch information
oviirup committed Jan 4, 2025
1 parent c2edf90 commit cc2b531
Show file tree
Hide file tree
Showing 4 changed files with 13 additions and 8 deletions.
5 changes: 5 additions & 0 deletions .changeset/wet-badgers-invent.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
'@oviirup/sprite': patch
---

🔧 updated package.json config pattern
2 changes: 1 addition & 1 deletion src/bin.ts
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ SpriteCLI.parseAsync().catch(() => process.exit(1));
// exit process on termination
for (const signal of ['SIGINT', 'SIGTERM', 'SIGQUIT', 'SIGKILL']) {
process.on(signal, () => {
logger.log(pi.yellow, 'Exiting ...');
logger.warn('Exiting ...');
process.stdout.write('\x1B[?25h');
process.exit();
});
Expand Down
2 changes: 1 addition & 1 deletion src/lib/build.ts
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ export function build(config: Partial<SpriteConfig> = {}) {
if (cfg.watch) {
logger.log('watching files');
for (const entry of cfg.entries) {
logger.log(null, pi.dim(`${entry}`));
logger.log(null, entry);
}
const watcher = chokidar.watch(cfg.entries, {
ignoreInitial: true,
Expand Down
12 changes: 6 additions & 6 deletions src/utils/logger.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,12 @@ import pi from 'picocolors';
import { ZodError } from 'zod';

function customLogger(first: string | Function | null, ...rest: string[]) {
if (typeof first === 'function') {
return console.log(first('[SPRITE]'), ...rest);
} else if (first === null) {
return console.log(' ', ...rest);
}
return console.log('[SPRITE]', first, ...rest);
rest = rest.map((msg) => pi.dim(` ${msg}`));
typeof first === 'function'
? console.log(first('[SPRITE]'), ...rest)
: first === null
? console.log(...rest)
: console.log('[SPRITE]', first, ...rest);
}

export const logger = {
Expand Down

0 comments on commit cc2b531

Please sign in to comment.