From 829328bdb064b817cbefe74dc303090c488eb538 Mon Sep 17 00:00:00 2001 From: Ben McCann <322311+benmccann@users.noreply.github.com> Date: Sat, 29 Jun 2024 08:20:49 -0700 Subject: [PATCH] remove rimraf dependency --- lib/clean.js | 9 +++------ lib/util/napi.js | 6 ++---- package-lock.json | 1 - package.json | 1 - 4 files changed, 5 insertions(+), 12 deletions(-) diff --git a/lib/clean.js b/lib/clean.js index 02ae7a678..f3e9058ca 100644 --- a/lib/clean.js +++ b/lib/clean.js @@ -4,8 +4,8 @@ module.exports = exports = clean; exports.usage = 'Removes the entire folder containing the compiled .node module'; -const { rimraf } = require('rimraf'); -const exists = require('fs').exists || require('path').exists; +const fs = require('fs'); +const exists = fs.exists || require('path').exists; const versioning = require('./util/versioning.js'); const napi = require('./util/napi.js'); const path = require('path'); @@ -23,10 +23,7 @@ function clean(gyp, argv, callback) { exists(to_delete, (found) => { if (found) { if (!gyp.opts.silent_clean) console.log('[' + package_json.name + '] Removing "%s"', to_delete); - return rimraf(to_delete).then( - (result) => callback(null, result), - (err) => callback(err) - ); + return fs.rm(to_delete, { recursive: true, force: true }, callback); } return callback(); }); diff --git a/lib/util/napi.js b/lib/util/napi.js index bb442fcd1..46fe40dce 100644 --- a/lib/util/napi.js +++ b/lib/util/napi.js @@ -166,16 +166,14 @@ module.exports.get_napi_build_version_from_command_args = function(command_args) module.exports.swap_build_dir_out = function(napi_build_version) { if (napi_build_version) { - const { rimrafSync } = require('rimraf'); - rimrafSync(module.exports.get_build_dir(napi_build_version)); + fs.rmSync(module.exports.get_build_dir(napi_build_version), { recursive: true, force: true }); fs.renameSync('build', module.exports.get_build_dir(napi_build_version)); } }; module.exports.swap_build_dir_in = function(napi_build_version) { if (napi_build_version) { - const { rimrafSync } = require('rimraf'); - rimrafSync('build'); + fs.rmSync('build', { recursive: true, force: true }); fs.renameSync(module.exports.get_build_dir(napi_build_version), 'build'); } }; diff --git a/package-lock.json b/package-lock.json index 299e3e71c..43fbdd2a2 100644 --- a/package-lock.json +++ b/package-lock.json @@ -15,7 +15,6 @@ "node-fetch": "^2.6.7", "nopt": "^5.0.0", "npmlog": "^7.0.1", - "rimraf": "^5.0.5", "semver": "^7.3.5", "tar": "^7.4.0" }, diff --git a/package.json b/package.json index fea24ccf5..ba8266a67 100644 --- a/package.json +++ b/package.json @@ -26,7 +26,6 @@ "node-fetch": "^2.6.7", "nopt": "^5.0.0", "npmlog": "^7.0.1", - "rimraf": "^5.0.5", "semver": "^7.3.5", "tar": "^7.4.0" },