* Deletes a name from the filesystem and possibly the file it refers to. Has * no effect if the file does not exist. * @param {string} aPath The path to remove. * @return {!Promise} A promise for when the file has been removed.
(aPath)
| 162 | * @return {!Promise} A promise for when the file has been removed. |
| 163 | */ |
| 164 | function unlink(aPath) { |
| 165 | return new Promise(function (fulfill, reject) { |
| 166 | const exists = fs.existsSync(aPath) |
| 167 | if (exists) { |
| 168 | fs.unlink(aPath, function (err) { |
| 169 | ;(err && reject(err)) || fulfill() |
| 170 | }) |
| 171 | } else { |
| 172 | fulfill() |
| 173 | } |
| 174 | }) |
| 175 | } |
| 176 | |
| 177 | /** |
| 178 | * @return {!Promise<string>} A promise for the path to a temporary directory. |