Skip to content

Commit

Permalink
Dogfoodin' is underrated
Browse files Browse the repository at this point in the history
webpro committed Jun 7, 2024

Verified

This commit was created on GitHub.com and signed with GitHub’s verified signature. The key has expired.
1 parent 0651144 commit 7115889
Showing 2 changed files with 3 additions and 13 deletions.
12 changes: 1 addition & 11 deletions packages/knip/src/util/debug.ts
Original file line number Diff line number Diff line change
@@ -1,12 +1,10 @@
import util from 'node:util';
import picocolors from 'picocolors';
import parsedArgValues from './cli-arguments.js';
import { relative } from './path.js';

const { debug, trace } = parsedArgValues;
const { debug } = parsedArgValues;

const IS_DEBUG_ENABLED = debug ?? false;
const IS_TRACE_ENABLED = trace ?? false;

const noop = () => {};

@@ -43,11 +41,3 @@ export const debugLogArray = IS_DEBUG_ENABLED
logArray(collection);
}
: noop;

const levels = ['①', '②', '③', '④', '⑤', '⑥', '⑦', '⑧', '⑨', '⑩', '⑪', '⑫', '⑬', '⑭', '⑮', '⑯'];
export const exportLookupLog = IS_TRACE_ENABLED
? (depth: number, message: string, filePath: string) => {
if (depth === -1) console.log(`\n${message}`, relative(filePath));
else console.log(new Array(depth + 1).join(' '), levels[depth], message, relative(filePath));
}
: noop;
4 changes: 2 additions & 2 deletions packages/knip/src/util/trace.ts
Original file line number Diff line number Diff line change
@@ -27,13 +27,13 @@ export type TraceNode = {

export { isTrace };

export const getPadding = (level: number, levels: Set<number>) => {
const getPadding = (level: number, levels: Set<number>) => {
let padding = '';
for (let i = 0; i < level; i++) padding += levels.has(i) ? `${picocolors.dim('│')} ` : ' ';
return padding;
};

export const renderTrace = (node: TraceNode, level = 0, levels = new Set<number>()) => {
const renderTrace = (node: TraceNode, level = 0, levels = new Set<number>()) => {
let index = 0;
const size = node.children.size;
const padding = getPadding(level, levels);

0 comments on commit 7115889

Please sign in to comment.