Skip to content

Commit ab12917

Browse files
committed
Section 24: A Buggy Initial Implementation
1 parent 7b65282 commit ab12917

1 file changed

Lines changed: 11 additions & 9 deletions

File tree

  • 24-Create-Node-JS-Command-Line-Tools/02-list

24-Create-Node-JS-Command-Line-Tools/02-list/index.js

Lines changed: 11 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -4,17 +4,19 @@
44
const fs = require('fs')
55

66
fs.readdir(process.cwd(), (err, filenames) => {
7-
// EITHER
8-
// err === an error object, which means something went wrong
9-
// OR
10-
// err === null, which means everything is OK
11-
127
if (err) {
13-
// error handling code here
14-
158
console.log(err)
16-
// return
179
}
10+
// console.log(filenames)
1811

19-
console.log(filenames)
12+
// BAD CODE HERE!!!!
13+
for(let filename of filenames) {
14+
fs.lstat(filename, (err, stats) => {
15+
if(err) {
16+
console.log(err);
17+
}
18+
19+
console.log(filename, stats.isFile());
20+
})
21+
}
2022
})

0 commit comments

Comments
 (0)