Skip to content

Commit

Permalink
Refactor deleteDirectoryRecursive function to correctly check if a pa…
Browse files Browse the repository at this point in the history
…th is a directory.

- Fix an issue where the code was not correctly checking if a path is a directory in the deleteDirectoryRecursive function.
- Update the condition to use await fs.lstat(curPath).isDirectory() instead of (await fs.lstat(curPath)).isDirectory().
  • Loading branch information
zanhk committed Sep 11, 2023
1 parent 2d49d0d commit 97f1c1b
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion bin/cli.js
Original file line number Diff line number Diff line change
Expand Up @@ -159,7 +159,7 @@ async function deleteDirectoryRecursive(directoryPath) {
if (await exists(directoryPath)) {
(await fs.readdir(directoryPath)).forEach(async (file, index) => {
const curPath = path.join(directoryPath, file);
if (await fs.lstat(curPath).isDirectory()) {
if ((await fs.lstat(curPath)).isDirectory()) {
// Recursive delete if it's a directory
await deleteDirectoryRecursive(curPath);
} else {
Expand Down

0 comments on commit 97f1c1b

Please sign in to comment.