How to use the unlinkSync function from graceful-fs

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

282
283
284
285
286
287
288
289
290
      rmdirSync(childPath);
    }

    results.push(...removed);
  } else {
    fs.unlinkSync(childPath);
    results.push(currentPath);
  }
}
fork icon9
star icon48
watch icon0

+ 23 other calls in file

67
68
69
70
71
72
73
74
75
76
  stream.write('second write ' + i + '\n')
})

setTimeout(function () {
  // Oops!  Deleted the file!
  fs.unlinkSync(target)

  // write some more stuff.
  streams.forEach(function (stream, i) {
    stream.write('third write ' + i + '\n')
fork icon1
star icon1
watch icon0

35
36
37
38
39
40
41
42
43
44
    return moveSyncAcrossDevice(src, dest, overwrite)
  }
} else {
  try {
    fs.linkSync(src, dest)
    return fs.unlinkSync(src)
  } catch (err) {
    if (err.code === 'EXDEV' || err.code === 'EISDIR' || err.code === 'EPERM' || err.code === 'ENOTSUP') {
      return moveSyncAcrossDevice(src, dest, overwrite)
    }
fork icon0
star icon1
watch icon0

2256
2257
2258
2259
2260
2261
2262
2263
2264
2265
const socket = new net.Socket();

socket.on("error", (error) => {
  if (error.code === "ECONNREFUSED") {
    // No other server listening on this socket so it can be safely removed
    fs.unlinkSync(this.options.ipc);

    resolve();

    return;
fork icon0
star icon0
watch icon1

+ 6 other calls in file

3212
3213
3214
3215
3216
3217
3218
3219
3220
3221
 * @param {Error & { code?: string }} error
 */
(error) => {
  if (error.code === "ECONNREFUSED") {
    // No other server listening on this socket so it can be safely removed
    fs.unlinkSync(/** @type {string} */ (this.options.ipc));

    resolve();

    return;
fork icon0
star icon0
watch icon1

+ 5 other calls in file

239
240
241
242
243
244
245
246
247
248
  }

  status.saved = true;
} else if (!hasExternalSnapshots && jestExistsFile(this._snapshotPath)) {
  if (this._updateSnapshot === 'all') {
    fs.unlinkSync(this._snapshotPath);
  }

  status.deleted = true;
}
fork icon0
star icon0
watch icon1

191
192
193
194
195
196
197
198
199
200
  return false;
}

if (!fileExists(testPath, hasteFS)) {
  if (update === 'all') {
    fs.unlinkSync(snapshotFile);
  }

  return true;
}
fork icon0
star icon0
watch icon1

165
166
167
168
169
170
171
172
173
174
  writeStream.__atomicClosed = true
  writeStream.emit('close')
}
function cleanupSync () {
  try {
    fs.unlinkSync(writeStream.__atomicTmp)
  } finally {
    return
  }
}
fork icon0
star icon0
watch icon0

6
7
8
9
10
11
12
13
14
15
var clobber = options.clobber
var preserveTimestamps = options.preserveTimestamps

if (fs.existsSync(destFile)) {
  if (clobber) {
    fs.unlinkSync(destFile)
  } else {
    var err = new Error('EEXIST: ' + destFile + ' already exists.')
    err.code = 'EEXIST'
    err.errno = -17
fork icon0
star icon0
watch icon0

53
54
55
56
57
58
59
60
61
62
63
  return mayCopyFile(srcStat, src, dest, opts)
}


function mayCopyFile (srcStat, src, dest, opts) {
  if (opts.overwrite) {
    fs.unlinkSync(dest)
    return copyFile(srcStat, src, dest, opts)
  } else if (opts.errorOnExist) {
    throw new Error(`'${dest}' already exists`)
  }
fork icon0
star icon0
watch icon0

+ 5 other calls in file

34
35
36
37
38
39
40
41
42
43
44
}


function cleanupOnExit (tmpfile) {
  return function () {
    try {
      fs.unlinkSync(typeof tmpfile === 'function' ? tmpfile() : tmpfile)
    } catch (_) {}
  }
}

fork icon0
star icon0
watch icon0

+ 3 other calls in file

120
121
122
123
124
125
126
127
128
    fs.closeSync(fd)
    if (options.chown) fs.chownSync(tmpfile, options.chown.uid, options.chown.gid)
    if (options.mode) fs.chmodSync(tmpfile, options.mode)
    fs.renameSync(tmpfile, filename)
  } catch (err) {
    try { fs.unlinkSync(tmpfile) } catch (e) {}
    throw err
  }
}
fork icon0
star icon0
watch icon0

+ 2 other calls in file