Skip to content

Commit 84e256a

Browse files
committed
fix: prevent clipboard from showing ANSI escaped string when using -c option (fix #7)
1 parent 93e4dde commit 84e256a

File tree

1 file changed

+5
-1
lines changed

1 file changed

+5
-1
lines changed

src/generate.ts

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,10 @@ export function generate(data: TreeNode[], options: Options, deep = 0) {
2323
index === data!.length - 1 ? characters.last : characters.contain
2424
contentPrefix += characters.line.repeat(2)
2525

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

3538
const isLastItemDirectory =
3639
index === data!.length - 1 && item.type === NodeTypes.DIRECTORY
40+
3741
lastDirStack[deep] = isLastItemDirectory
3842

3943
if (item.children && item.children.length > 0) {

0 commit comments

Comments
 (0)