* Read a directory without throwing an error is the directory doesn't exist * * @param {string} filepath - The path to the directory. * @returns {Promise } - An array of file names, or `null` if the path is not a directory.
(filepath)
| 223 | * @returns {Promise<string[]|null>} - An array of file names, or `null` if the path is not a directory. |
| 224 | */ |
| 225 | async readdir(filepath) { |
| 226 | try { |
| 227 | const names = await this._readdir(filepath) |
| 228 | // Ordering is not guaranteed, and system specific (Windows vs Unix) |
| 229 | // so we must sort them ourselves. |
| 230 | names.sort(compareStrings) |
| 231 | return names |
| 232 | } catch (err) { |
| 233 | if (err.code === 'ENOTDIR') return null |
| 234 | return [] |
| 235 | } |
| 236 | } |
| 237 | |
| 238 | /** |
| 239 | * Return a flat list of all the files nested inside a directory |
no outgoing calls
no test coverage detected