Skip to content

Commit e6570b6

Browse files
committed
Section 24: Issues with Sequential Reads
1 parent fd6dbbe commit e6570b6

1 file changed

Lines changed: 12 additions & 2 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: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,12 +8,22 @@ const util = require('util')
88
// const lstat = util.promisify(fs.lstat)
99

1010
// Method #3
11-
const { lstat } = fs.promises
11+
// const { lstat } = fs.promises
1212

13-
fs.readdir(process.cwd(), (err, filenames) => {
13+
fs.readdir(process.cwd(), async (err, filenames) => {
1414
if (err) {
1515
console.log(err)
1616
}
17+
18+
for (let filename of filenames) {
19+
try {
20+
const stats = await lstat(filename)
21+
22+
console.log(filename, stats.isFile())
23+
} catch (err) {
24+
console.log(err)
25+
}
26+
}
1727
})
1828

1929
// Method #1

0 commit comments

Comments
 (0)