From c766727f3898235a2245adbc0f854b5f8bb5e552 Mon Sep 17 00:00:00 2001 From: Ryan Zimmerman Date: Fri, 2 Apr 2021 18:00:48 -0400 Subject: [PATCH] BREAKING: Use fs.rm/rmSync where supported Fixes #806 Technically a breaking change since this removes the undocumented ability to pass options to remove*() --- lib/remove/index.js | 17 +++++++++++++++-- 1 file changed, 15 insertions(+), 2 deletions(-) diff --git a/lib/remove/index.js b/lib/remove/index.js index cee534007..4428e59ad 100644 --- a/lib/remove/index.js +++ b/lib/remove/index.js @@ -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 }