Skip to content

Commit 4fdb357

Browse files
committed
validating the path first
1 parent d2daa0e commit 4fdb357

1 file changed

Lines changed: 5 additions & 0 deletions

File tree

  • implement-shell-tools/ls

implement-shell-tools/ls/ls.js

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,11 @@ const path = program.args[0];
1515

1616
const options = program.opts();
1717

18+
if (!path) {
19+
console.error("Error: No directory path was provided.");
20+
process.exit(1);
21+
}
22+
1823
const directoryContent = await fs.readdir(path);
1924

2025
let allContent = directoryContent;

0 commit comments

Comments
 (0)