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 29, 2024
1 parent 1377310 commit aaea73e
Show file tree
Hide file tree
Showing 4 changed files with 9 additions and 12 deletions.
13 changes: 7 additions & 6 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 { 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');
Expand All @@ -23,10 +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 rimraf(to_delete).then(
(result) => callback(null, result),
(err) => callback(err)
);
try {
fs.rmSync(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 { 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');
}
};
Expand Down
1 change: 0 additions & 1 deletion 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": "^5.0.5",
"semver": "^7.3.5",
"tar": "^7.4.0"
},
Expand Down

0 comments on commit aaea73e

Please sign in to comment.