From fd20718ff86c32884151cd216530bad5148523c1 Mon Sep 17 00:00:00 2001 From: Sylvester Keil Date: Thu, 6 Aug 2020 09:10:11 +0200 Subject: [PATCH 1/2] remove rimraf The `recursive` option for `fs.rmdir` was added in Node.js 12.10.0. This sets `maxRetries` to 3, because that was the default value used by rimraf. --- index.js | 5 ++--- package.json | 3 --- test/unzip.js | 7 +++---- test/zip.js | 5 ++--- 4 files changed, 7 insertions(+), 13 deletions(-) diff --git a/index.js b/index.js index b2f601c..52fb9ad 100644 --- a/index.js +++ b/index.js @@ -10,7 +10,6 @@ var cp = require('child_process') var fs = require('fs') var os = require('os') var path = require('path') -var rimraf = require('rimraf') function zip (inPath, outPath, cb) { if (!cb) cb = function () {} @@ -47,7 +46,7 @@ function zip (inPath, outPath, cb) { // Windows zip command does not overwrite existing files. So do it manually first. function doZip () { if (process.platform === 'win32') { - rimraf(outPath, doZip2) + fs.rmdir(outPath, { recursive: true, maxRetries: 3 }, doZip2) } else { doZip2() } @@ -73,7 +72,7 @@ function zipSync (inPath, outPath) { fs.writeFileSync(path.join(tmpPath, path.basename(inPath)), inFile) inPath = tmpPath } - rimraf.sync(outPath) + fs.rmdirSync(outPath, { recursive: true, maxRetries: 3 }) } var opts = { cwd: path.dirname(inPath), diff --git a/package.json b/package.json index 38b4d83..4df7535 100644 --- a/package.json +++ b/package.json @@ -34,9 +34,6 @@ "scripts": { "test": "standard && tape test/*.js" }, - "dependencies": { - "rimraf": "^3.0.0" - }, "funding": [ { "type": "github", diff --git a/test/unzip.js b/test/unzip.js index a8b7eb3..5abaff3 100644 --- a/test/unzip.js +++ b/test/unzip.js @@ -1,6 +1,5 @@ var fs = require('fs') var path = require('path') -var rimraf = require('rimraf') var test = require('tape') var zip = require('../') @@ -12,7 +11,7 @@ fs.mkdirSync(tmpPath, { recursive: true }) test('unzipSync', function (t) { var tmpFilePath = path.join(tmpPath, 'file.txt') - rimraf.sync(tmpFilePath) + fs.rmdirSync(tmpFilePath, { recursive: true }) zip.unzipSync(fileZipPath, tmpPath) var tmpFile = fs.readFileSync(tmpFilePath) @@ -26,7 +25,7 @@ test('unzip', function (t) { t.plan(3) var tmpFilePath = path.join(tmpPath, 'file.txt') - rimraf(tmpFilePath, function (err) { + fs.rmdir(tmpFilePath, { recursive: true }, function (err) { t.error(err) zip.unzip(fileZipPath, tmpPath, function (err) { @@ -48,7 +47,7 @@ test('unzip from a folder with a space in it', function (t) { fs.copyFileSync(fileZipPath, zipSpacePath) var tmpFilePath = path.join(tmpPath, 'file.txt') - rimraf(tmpFilePath, function (err) { + fs.rmdir(tmpFilePath, { recursive: true }, function (err) { t.error(err) zip.unzip(zipSpacePath, tmpPath, function (err) { diff --git a/test/zip.js b/test/zip.js index 73be28a..0489bd5 100644 --- a/test/zip.js +++ b/test/zip.js @@ -1,6 +1,5 @@ var fs = require('fs') var path = require('path') -var rimraf = require('rimraf') var test = require('tape') var zip = require('../') @@ -14,7 +13,7 @@ test('zipSync', function (t) { zip.zipSync(filePath, tmpFileZipPath) var tmpFilePath = path.join(tmpPath, 'file.txt') - rimraf.sync(tmpFilePath) + fs.rmdirSync(tmpFilePath, { recursive: true }) zip.unzipSync(tmpFileZipPath, tmpPath) var tmpFile = fs.readFileSync(tmpFilePath) @@ -32,7 +31,7 @@ test('zip', function (t) { t.error(err) var tmpFilePath = path.join(tmpPath, 'file.txt') - rimraf(tmpFilePath, function (err) { + fs.rmdir(tmpFilePath, { recursive: true }, function (err) { t.error(err) zip.unzip(tmpFileZipPath, tmpPath, function (err) { From df07b27930dda7e13afd3d593d6dc7f13a908c1a Mon Sep 17 00:00:00 2001 From: Sylvester Keil Date: Thu, 6 Aug 2020 09:24:10 +0200 Subject: [PATCH 2/2] Add node version requirement --- package.json | 3 +++ 1 file changed, 3 insertions(+) diff --git a/package.json b/package.json index 4df7535..be604ce 100644 --- a/package.json +++ b/package.json @@ -34,6 +34,9 @@ "scripts": { "test": "standard && tape test/*.js" }, + "engines": { + "node": ">=12.10" + }, "funding": [ { "type": "github",