-
Notifications
You must be signed in to change notification settings - Fork 35
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Remove
empty-dir
dependency and add our own implementation (#935)
- Loading branch information
Showing
5 changed files
with
27 additions
and
11 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
--- | ||
'sku': patch | ||
--- | ||
|
||
Remove `empty-dir` dependency |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
const { statSync, readdirSync } = require('node:fs'); | ||
|
||
/** | ||
* Returns whether the given directory is empty, throwing if the path is not a directory | ||
* @typedef {import('fs').PathLike} PathLike | ||
* @param {PathLike} path A path to a directory | ||
*/ | ||
const isEmptyDir = (path) => { | ||
const isDirectory = statSync(path).isDirectory(); | ||
|
||
if (!isDirectory) { | ||
throw new Error(`${path} is not a directory`); | ||
} | ||
|
||
const files = readdirSync(path); | ||
|
||
return files.length === 0; | ||
}; | ||
|
||
module.exports = { isEmptyDir }; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.