@xhmikosr/decompress
Advanced tools
Comparing version 5.0.0 to 6.0.0
50
index.js
import {Buffer} from 'node:buffer'; | ||
import path from 'node:path'; | ||
import process from 'node:process'; | ||
import {promisify} from 'node:util'; | ||
import decompressTar from 'decompress-tar'; | ||
@@ -10,6 +11,11 @@ import decompressTarbz2 from 'decompress-tarbz2'; | ||
import makeDir from 'make-dir'; | ||
import pify from 'pify'; | ||
import stripDirs from 'strip-dirs'; | ||
const fsP = pify(fs); | ||
const link = promisify(fs.link); | ||
const readFile = promisify(fs.readFile); | ||
const readlink = promisify(fs.readlink); | ||
const realpath = promisify(fs.realpath); | ||
const symlink = promisify(fs.symlink); | ||
const utimes = promisify(fs.utimes); | ||
const writeFile = promisify(fs.writeFile); | ||
@@ -22,7 +28,7 @@ const runPlugins = (input, options) => { | ||
return Promise.all(options.plugins.map(x => x(input, options))) | ||
// eslint-disable-next-line unicorn/no-array-reduce, unicorn/prefer-spread | ||
.then(files => files.reduce((a, b) => a.concat(b))); | ||
// eslint-disable-next-line unicorn/no-array-reduce | ||
.then(files => files.reduce((a, b) => [...a, ...b])); | ||
}; | ||
const safeMakeDir = (dir, realOutputPath) => fsP.realpath(dir) | ||
const safeMakeDir = (dir, realOutputPath) => realpath(dir) | ||
.catch(_ => { | ||
@@ -37,6 +43,6 @@ const parent = path.dirname(dir); | ||
return makeDir(dir).then(fsP.realpath); | ||
return makeDir(dir).then(realpath); | ||
}); | ||
const preventWritingThroughSymlink = (destination, realOutputPath) => fsP.readlink(destination) | ||
const preventWritingThroughSymlink = (destination, realOutputPath) => readlink(destination) | ||
// Either no file exists, or it's not a symlink. In either case, this is | ||
@@ -85,5 +91,5 @@ // not an escape we need to worry about in this phase. | ||
return makeDir(output) | ||
.then(outputPath => fsP.realpath(outputPath)) | ||
.then(outputPath => realpath(outputPath)) | ||
.then(realOutputPath => safeMakeDir(dest, realOutputPath)) | ||
.then(() => fsP.utimes(dest, now, x.mtime)) | ||
.then(() => utimes(dest, now, x.mtime)) | ||
.then(() => x); | ||
@@ -93,3 +99,3 @@ } | ||
return makeDir(output) | ||
.then(outputPath => fsP.realpath(outputPath)) | ||
.then(outputPath => realpath(outputPath)) | ||
.then(realOutputPath => | ||
@@ -99,10 +105,6 @@ // Attempt to ensure parent directory exists (failing if it's outside the output dir) | ||
) | ||
.then(realOutputPath => { | ||
if (x.type === 'file') { | ||
return preventWritingThroughSymlink(dest, realOutputPath); | ||
} | ||
return realOutputPath; | ||
}) | ||
.then(realOutputPath => fsP.realpath(path.dirname(dest)) | ||
.then(realOutputPath => x.type === 'file' | ||
? preventWritingThroughSymlink(dest, realOutputPath) | ||
: realOutputPath) | ||
.then(realOutputPath => realpath(path.dirname(dest)) | ||
.then(realDestinationDir => { | ||
@@ -115,16 +117,16 @@ if (realDestinationDir.indexOf(realOutputPath) !== 0) { | ||
if (x.type === 'link') { | ||
return fsP.link(x.linkname, dest); | ||
return link(x.linkname, dest); | ||
} | ||
if (x.type === 'symlink' && process.platform === 'win32') { | ||
return fsP.link(x.linkname, dest); | ||
return link(x.linkname, dest); | ||
} | ||
if (x.type === 'symlink') { | ||
return fsP.symlink(x.linkname, dest); | ||
return symlink(x.linkname, dest); | ||
} | ||
return fsP.writeFile(dest, x.data, {mode}); | ||
return writeFile(dest, x.data, {mode}); | ||
}) | ||
.then(() => x.type === 'file' && fsP.utimes(dest, now, x.mtime)) | ||
.then(() => x.type === 'file' && utimes(dest, now, x.mtime)) | ||
.then(() => x); | ||
@@ -154,3 +156,3 @@ })); | ||
const read = typeof input === 'string' ? fsP.readFile(input) : Promise.resolve(input); | ||
const read = typeof input === 'string' ? readFile(input) : Promise.resolve(input); | ||
@@ -157,0 +159,0 @@ return read.then(buf => extractFile(buf, output, options)); |
{ | ||
"name": "@xhmikosr/decompress", | ||
"version": "5.0.0", | ||
"version": "6.0.0", | ||
"description": "Extracting archives made easy", | ||
"license": "MIT", | ||
"repository": "XhmikosR/decompress", | ||
"publishConfig": { | ||
"access": "public" | ||
}, | ||
"author": { | ||
"name": "Kevin Mårtensson", | ||
"email": "kevinmartensson@gmail.com", | ||
"url": "github.com/kevva" | ||
"url": "https://github.com/kevva" | ||
}, | ||
"engines": { | ||
"node": "^12.20.0 || ^14.14.0 || >=16.0.0" | ||
"node": "^14.14.0 || >=16.0.0" | ||
}, | ||
"scripts": { | ||
"ava": "ava", | ||
"lint": "xo", | ||
"xo": "xo", | ||
"fix": "xo --fix", | ||
"test": "npm run xo && npm run ava", | ||
"test-ci": "npm run xo && c8 ava" | ||
"test-ci": "c8 ava" | ||
}, | ||
@@ -45,15 +50,13 @@ "main": "index.js", | ||
"decompress-unzip": "^4.0.1", | ||
"graceful-fs": "^4.2.10", | ||
"graceful-fs": "^4.2.11", | ||
"make-dir": "^3.1.0", | ||
"pify": "^5.0.0", | ||
"strip-dirs": "^3.0.0" | ||
}, | ||
"devDependencies": { | ||
"ava": "^4.3.0", | ||
"c8": "^7.11.3", | ||
"ava": "^5.3.0", | ||
"c8": "^7.13.0", | ||
"is-jpg": "^3.0.0", | ||
"path-exists": "^5.0.0", | ||
"rimraf": "^3.0.2", | ||
"xo": "^0.49.0" | ||
"xo": "^0.54.2" | ||
} | ||
} |
@@ -1,2 +0,2 @@ | ||
# decompress [![CI](https://github.com/XhmikosR/decompress/actions/workflows/ci.yml/badge.svg)](https://github.com/XhmikosR/decompress/actions/workflows/ci.yml) | ||
# decompress [![CI](https://github.com/XhmikosR/decompress/actions/workflows/ci.yml/badge.svg?branch=master)](https://github.com/XhmikosR/decompress/actions/workflows/ci.yml) | ||
@@ -3,0 +3,0 @@ > Extracting archives made easy |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
8850
7
5
131
- Removedpify@^5.0.0
- Removedpify@5.0.0(transitive)
Updatedgraceful-fs@^4.2.11