Skip to content

Commit

Permalink
remove rimraf dependency
Browse files Browse the repository at this point in the history
  • Loading branch information
benmccann committed Jun 27, 2024
1 parent a74f5e3 commit c6b2b06
Show file tree
Hide file tree
Showing 4 changed files with 40 additions and 18 deletions.
10 changes: 7 additions & 3 deletions lib/clean.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,8 @@ module.exports = exports = clean;

exports.usage = 'Removes the entire folder containing the compiled .node module';

const rm = 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');
Expand All @@ -23,7 +23,11 @@ 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 rm(to_delete, callback);
try {
fs.rmdirSync(to_delete, { recursive: true, force: true });
} catch (err) {
return callback(err);
}
}
return callback();
});
Expand Down
6 changes: 2 additions & 4 deletions lib/util/napi.js
Original file line number Diff line number Diff line change
Expand Up @@ -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 rm = require('rimraf');
rm.sync(module.exports.get_build_dir(napi_build_version));
fs.rmdirSync(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 rm = require('rimraf');
rm.sync('build');
fs.rmdirSync('build', { recursive: true, force: true });
fs.renameSync(module.exports.get_build_dir(napi_build_version), 'build');
}
};
Expand Down
41 changes: 31 additions & 10 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 0 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,6 @@
"node-fetch": "^2.6.7",
"nopt": "^5.0.0",
"npmlog": "^5.0.1",
"rimraf": "^3.0.2",
"semver": "^7.3.5",
"tar": "^6.1.11"
},
Expand Down

0 comments on commit c6b2b06

Please sign in to comment.