Skip to content

Commit c8815e3

Browse files
authored
BREAKING: Use fs.rm/rmSync where supported (#882)
Fixes #806 Technically a breaking change since this removes the undocumented ability to pass options to remove*()
1 parent 24731f1 commit c8815e3

File tree

1 file changed

+15
-2
lines changed

1 file changed

+15
-2
lines changed

lib/remove/index.js

Lines changed: 15 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,22 @@
11
'use strict'
22

3+
const fs = require('graceful-fs')
34
const u = require('universalify').fromCallback
45
const rimraf = require('./rimraf')
56

7+
function remove (path, callback) {
8+
// Node 14.14.0+
9+
if (fs.rm) return fs.rm(path, { recursive: true, force: true }, callback)
10+
rimraf(path, callback)
11+
}
12+
13+
function removeSync (path) {
14+
// Node 14.14.0+
15+
if (fs.rmSync) return fs.rmSync(path, { recursive: true, force: true })
16+
rimraf.sync(path)
17+
}
18+
619
module.exports = {
7-
remove: u(rimraf),
8-
removeSync: rimraf.sync
20+
remove: u(remove),
21+
removeSync
922
}

0 commit comments

Comments
 (0)