There was an error while loading. Please reload this page.
1 parent 34e4119 commit 5729de7Copy full SHA for 5729de7
1 file changed
24-Create-Node-JS-Command-Line-Tools/02-list/index.js
@@ -4,6 +4,7 @@
4
const fs = require('fs')
5
const util = require('util')
6
const chalk = require('chalk')
7
+const path = require('path')
8
9
// Method #2
10
// const lstat = util.promisify(fs.lstat)
@@ -15,14 +16,13 @@ const { lstat } = fs.promises
15
16
17
const targetDir = process.argv[2] || process.cwd()
18
-// fs.readdir(process.cwd(), async (err, filenames) => {
19
fs.readdir(targetDir, async (err, filenames) => {
20
if (err) {
21
console.log(err)
22
}
23
24
const statPromises = filenames.map((filename) => {
25
- return lstat(filename)
+ return lstat(path.join(targetDir, filename))
26
})
27
28
const allStats = await Promise.all(statPromises)
0 commit comments