Skip to content

Commit 5729de7

Browse files
committed
Section 24: Joining Paths
1 parent 34e4119 commit 5729de7

1 file changed

Lines changed: 2 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: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44
const fs = require('fs')
55
const util = require('util')
66
const chalk = require('chalk')
7+
const path = require('path')
78

89
// Method #2
910
// const lstat = util.promisify(fs.lstat)
@@ -15,14 +16,13 @@ const { lstat } = fs.promises
1516

1617
const targetDir = process.argv[2] || process.cwd()
1718

18-
// fs.readdir(process.cwd(), async (err, filenames) => {
1919
fs.readdir(targetDir, async (err, filenames) => {
2020
if (err) {
2121
console.log(err)
2222
}
2323

2424
const statPromises = filenames.map((filename) => {
25-
return lstat(filename)
25+
return lstat(path.join(targetDir, filename))
2626
})
2727

2828
const allStats = await Promise.all(statPromises)

0 commit comments

Comments
 (0)