Skip to content

Commit

Permalink
fix: prevent clipboard from showing ANSI escaped string when using `-…
Browse files Browse the repository at this point in the history
…c` option (fix #7)
  • Loading branch information
w2xi committed Jan 15, 2025
1 parent 93e4dde commit 84e256a
Showing 1 changed file with 5 additions and 1 deletion.
6 changes: 5 additions & 1 deletion src/generate.ts
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,10 @@ export function generate(data: TreeNode[], options: Options, deep = 0) {
index === data!.length - 1 ? characters.last : characters.contain
contentPrefix += characters.line.repeat(2)

const name = item.type === NodeTypes.DIRECTORY ? blue(item.name) : item.name
const name =
item.type === NodeTypes.DIRECTORY && !options.clipboard
? blue(item.name)
: item.name
const content = options.icon
? `${emoji[item.type as keyof typeof emoji]}${name}`
: `${name}`
Expand All @@ -34,6 +37,7 @@ export function generate(data: TreeNode[], options: Options, deep = 0) {

const isLastItemDirectory =
index === data!.length - 1 && item.type === NodeTypes.DIRECTORY

lastDirStack[deep] = isLastItemDirectory

if (item.children && item.children.length > 0) {
Expand Down

0 comments on commit 84e256a

Please sign in to comment.