Skip to content

Commit e679300

Browse files
committed
add checking condition if fileName is printed in terminal
1 parent 41a871e commit e679300

1 file changed

Lines changed: 2 additions & 2 deletions

File tree

implement-shell-tools/ls/customLs.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ async function formatFileName(base, fileName) {
1919
try {
2020
const fullPath = `${base.endsWith("/") ? base : base + "/"}${fileName}`;
2121
const stats = await fs.stat(fullPath);
22-
if (stats.isDirectory()) {
22+
if (stats.isDirectory() && process.stdout.isTTY) {
2323
return `\x1b[1;34m${fileName}\x1b[0m`;
2424
}
2525
return fileName;
@@ -64,7 +64,7 @@ try {
6464
if (stats && stats.isFile()) {
6565
console.log(path);
6666
} else {
67-
console.log(
67+
console.error(
6868
`Can't access to this path: ${path} - No such file or directory`,
6969
);
7070
process.exit(1);

0 commit comments

Comments
 (0)