Skip to content

Commit c6b2b06

Browse files
committed
remove rimraf dependency
1 parent a74f5e3 commit c6b2b06

4 files changed

Lines changed: 40 additions & 18 deletions

File tree

lib/clean.js

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,8 @@ module.exports = exports = clean;
44

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

7-
const rm = require('rimraf');
8-
const exists = require('fs').exists || require('path').exists;
7+
const fs = require('fs');
8+
const exists = fs.exists || require('path').exists;
99
const versioning = require('./util/versioning.js');
1010
const napi = require('./util/napi.js');
1111
const path = require('path');
@@ -23,7 +23,11 @@ function clean(gyp, argv, callback) {
2323
exists(to_delete, (found) => {
2424
if (found) {
2525
if (!gyp.opts.silent_clean) console.log('[' + package_json.name + '] Removing "%s"', to_delete);
26-
return rm(to_delete, callback);
26+
try {
27+
fs.rmdirSync(to_delete, { recursive: true, force: true });
28+
} catch (err) {
29+
return callback(err);
30+
}
2731
}
2832
return callback();
2933
});

lib/util/napi.js

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -166,16 +166,14 @@ module.exports.get_napi_build_version_from_command_args = function(command_args)
166166

167167
module.exports.swap_build_dir_out = function(napi_build_version) {
168168
if (napi_build_version) {
169-
const rm = require('rimraf');
170-
rm.sync(module.exports.get_build_dir(napi_build_version));
169+
fs.rmdirSync(module.exports.get_build_dir(napi_build_version), { recursive: true, force: true });
171170
fs.renameSync('build', module.exports.get_build_dir(napi_build_version));
172171
}
173172
};
174173

175174
module.exports.swap_build_dir_in = function(napi_build_version) {
176175
if (napi_build_version) {
177-
const rm = require('rimraf');
178-
rm.sync('build');
176+
fs.rmdirSync('build', { recursive: true, force: true });
179177
fs.renameSync(module.exports.get_build_dir(napi_build_version), 'build');
180178
}
181179
};

package-lock.json

Lines changed: 31 additions & 10 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,6 @@
2626
"node-fetch": "^2.6.7",
2727
"nopt": "^5.0.0",
2828
"npmlog": "^5.0.1",
29-
"rimraf": "^3.0.2",
3029
"semver": "^7.3.5",
3130
"tar": "^6.1.11"
3231
},

0 commit comments

Comments
 (0)