Skip to content

Commit

Permalink
BREAKING: Use fs.rm/rmSync where supported (#882)
Browse files Browse the repository at this point in the history
Fixes #806

Technically a breaking change since this removes the undocumented
ability to pass options to remove*()
  • Loading branch information
RyanZim authored Apr 8, 2021
1 parent 24731f1 commit c8815e3
Showing 1 changed file with 15 additions and 2 deletions.
17 changes: 15 additions & 2 deletions lib/remove/index.js
Original file line number Diff line number Diff line change
@@ -1,9 +1,22 @@
'use strict'

const fs = require('graceful-fs')
const u = require('universalify').fromCallback
const rimraf = require('./rimraf')

function remove (path, callback) {
// Node 14.14.0+
if (fs.rm) return fs.rm(path, { recursive: true, force: true }, callback)
rimraf(path, callback)
}

function removeSync (path) {
// Node 14.14.0+
if (fs.rmSync) return fs.rmSync(path, { recursive: true, force: true })
rimraf.sync(path)
}

module.exports = {
remove: u(rimraf),
removeSync: rimraf.sync
remove: u(remove),
removeSync
}

0 comments on commit c8815e3

Please sign in to comment.