* Tests if a file path exists. * @param {string} aPath The path to test. * @return {!Promise } A promise for whether the file exists.
(aPath)
| 136 | * @return {!Promise<boolean>} A promise for whether the file exists. |
| 137 | */ |
| 138 | function exists(aPath) { |
| 139 | return new Promise(function (fulfill, reject) { |
| 140 | let type = typeof aPath |
| 141 | if (type !== 'string') { |
| 142 | reject(TypeError(`expected string path, but got ${type}`)) |
| 143 | } else { |
| 144 | fulfill(fs.existsSync(aPath)) |
| 145 | } |
| 146 | }) |
| 147 | } |
| 148 | |
| 149 | /** |
| 150 | * Calls `stat(2)`. |