How to use the unlinkAsync function from fs

Find comprehensive JavaScript fs.unlinkAsync code examples handpicked from public code repositorys.

25
26
27
28
29
30
31
32
33
34
// If a dump exists, uncompress it & use it as a starting point
var dumpPromise = P.resolve();
if (fs.existsSync(dumpDB)) {
    dumpPromise = proc.execFileAsync('pixz', ['-d', dumpDB, workDB])
                    .catch(function() {
                        return fs.unlinkAsync(workDB);
                    });
}

return dumpPromise
fork icon6
star icon5
watch icon26

+ 3 other calls in file

286
287
288
289
290
291
292
293
294
295
/**
 * @private
 */
function _unlink(path, stream) {
  stream.emit('delete', path)
  return fs.unlinkAsync(path)
    .catch((err) => {
      // if no entry, file has been moved or removed - keep going
      if (err.code !== 'ENOENT') {
        throw err
fork icon1
star icon1
watch icon0

95
96
97
98
99
100
101
102
103
104
  try {
    await fs.renameAsync(file.path, join(uploadsFolder, fileName));
  } catch (e) {
    console.log("Error uploading the file");
    try {
      await fs.unlinkAsync(file.path);
    } catch (e) {}
    return res.json({ ok: false, msg: "Error uploading the file" });
  }
} else {
fork icon0
star icon0
watch icon0