From 6fa5d27c7f55a2c9b5e0f1209e8dbd73136f2e56 Mon Sep 17 00:00:00 2001 From: Mathias Buus Date: Sat, 17 Jun 2023 22:58:51 +0200 Subject: [PATCH] fix win (#106) --- index.js | 6 +++--- test/index.js | 15 +++++++++++++++ 2 files changed, 18 insertions(+), 3 deletions(-) diff --git a/index.js b/index.js index 5e6f437..ae0f79b 100644 --- a/index.js +++ b/index.js @@ -309,9 +309,9 @@ exports.extract = function extract (cwd, opts) { function validate (fs, name, root, cb) { if (name === root) return cb(null, true) fs.lstat(name, function (err, st) { - if (err && err.code !== 'ENOENT') return cb(err) - if (err || st.isDirectory()) return validate(fs, path.join(name, '..'), root, cb) - cb(null, false) + if (err && err.code === 'ENOENT') return validate(fs, path.join(name, '..'), root, cb) + else if (err) return cb(err) + cb(null, st.isDirectory()) }) } diff --git a/test/index.js b/test/index.js index ed713b4..727c378 100644 --- a/test/index.js +++ b/test/index.js @@ -294,6 +294,12 @@ test('not finalizing the pack', function (t) { }) test('do not extract invalid tar', function (t) { + if (win32) { // no symlink support on win32 currently. TODO: test if this can be enabled somehow + t.plan(1) + t.ok(true) + return + } + t.plan(2) const a = path.join(__dirname, 'fixtures', 'invalid.tar') @@ -310,9 +316,18 @@ test('do not extract invalid tar', function (t) { t.ok(err) }) }) + .on('finish', function () { + t.fail('should not finish') + }) }) test('no abs hardlink targets', function (t) { + if (win32) { // no symlink support on win32 currently. TODO: test if this can be enabled somehow + t.plan(1) + t.ok(true) + return + } + t.plan(3) const out = path.join(__dirname, 'fixtures', 'invalid')