Skip to content

Commit d4752a4

Browse files
committed
feat: one per line implemention
1 parent d379ae6 commit d4752a4

1 file changed

Lines changed: 8 additions & 1 deletion

File tree

  • implement-shell-tools/ls

implement-shell-tools/ls/ls.mjs

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,9 +16,16 @@ try {
1616

1717
for (const file of files) {
1818
if (options.a || !file.startsWith(".")) {
19-
console.log(file);
19+
process.stdout.write(file);
20+
if (options.onePerLine) {
21+
process.stdout.write("\n");
22+
} else {
23+
process.stdout.write(" ");
24+
}
2025
}
2126
}
2227
} catch (error) {
2328
console.error(error.message);
2429
}
30+
if(!options.onePerLine)
31+
console.log()

0 commit comments

Comments
 (0)