* Return true if a file exists, false if it doesn't exist. * Rethrows errors that aren't related to file existence. * * @param {string} filepath - The path to the file. * @param {Object} [options] - Additional options. * @returns {Promise } - `true` if the file exists, `false`
(filepath, options = {})
| 90 | * @returns {Promise<boolean>} - `true` if the file exists, `false` otherwise. |
| 91 | */ |
| 92 | async exists(filepath, options = {}) { |
| 93 | try { |
| 94 | await this._stat(filepath) |
| 95 | return true |
| 96 | } catch (err) { |
| 97 | if ( |
| 98 | err.code === 'ENOENT' || |
| 99 | err.code === 'ENOTDIR' || |
| 100 | (err.code || '').includes('ENS') |
| 101 | ) { |
| 102 | return false |
| 103 | } else { |
| 104 | console.log('Unhandled error in "FileSystem.exists()" function', err) |
| 105 | throw err |
| 106 | } |
| 107 | } |
| 108 | } |
| 109 | |
| 110 | /** |
| 111 | * Return the contents of a file if it exists, otherwise returns null. |
no outgoing calls
no test coverage detected