How to use the unlink function from graceful-fs

Find comprehensive JavaScript graceful-fs.unlink code examples handpicked from public code repositorys.

122
123
124
125
126
127
128
129
130
131
    })
  })
}

function rmFile (file, done) {
  fs.unlink(file, function (err) {
    if (err) return onError(err)
    return done()
  })
}
fork icon1
star icon0
watch icon0

95
96
97
98
99
100
101
102
103
104
function createPythonSymlink () {
  const symlinkDestination = path.join(buildBinsDir, 'python3')

  log.verbose('python symlink', `creating symlink to "${python}" at "${symlinkDestination}"`)

  fs.unlink(symlinkDestination, function (err) {
    if (err && err.code !== 'ENOENT') {
      log.verbose('python symlink', 'error when attempting to remove existing symlink')
      log.verbose('python symlink', err.stack, 'errno: ' + err.errno)
    }
fork icon0
star icon0
watch icon1

281
282
283
284
285
286
287
288
289
290
function symlink(srcPath, destPath, opts, callback) {
  // Because fs.symlink does not allow atomic overwrite option with flags, we
  // delete and recreate if the link already exists and overwrite is true.
  if (opts.flags === 'w') {
    // TODO What happens when we call unlink with windows junctions?
    fs.unlink(destPath, onUnlink);
  } else {
    fs.symlink(srcPath, destPath, opts.type, onSymlink);
  }

fork icon0
star icon0
watch icon1

132
133
134
135
136
137
138
139
140
141
    }
  }
}

function cleanup (err) {
  fs.unlink(writeStream.__atomicTmp, function () {
    if (err) {
      writeStream.emit('error', err)
      writeStream.emit('close')
    } else {
fork icon0
star icon0
watch icon0

162
163
164
165
166
167
168
169
170
171
}, function fail (err) {
  return new Promise(resolve => {
    return fd ? fs.close(fd, resolve) : resolve()
  }).then(() => {
    removeOnExitHandler()
    fs.unlink(tmpfile, function () {
      callback(err)
    })
  })
}).then(function checkQueue () {
fork icon0
star icon0
watch icon0

+ 3 other calls in file

53
54
55
56
57
58
59
60
61
    [writeFileAsync, tmpfile, data, options.mode, options.encoding || 'utf8'],
    options.chown && [fs, fs.chown, tmpfile, options.chown.uid, options.chown.gid],
    options.mode && [fs, fs.chmod, tmpfile, options.mode],
    [fs, fs.rename, tmpfile, filename]
  ], function (err) {
    err ? fs.unlink(tmpfile, function () { callback(err) })
      : callback()
  })
}
fork icon0
star icon0
watch icon0

+ 2 other calls in file