max-mapper / extract-zip

Zip extraction written in pure JavaScript. Extracts a zip into a directory.
BSD 2-Clause "Simplified" License
388 stars 126 forks source link

Error: Target directory is expected to be absolute #124

Open doremifaJ opened 2 years ago

doremifaJ commented 2 years ago

Why not support relative path?

eramudeep commented 2 years ago

Why not support relative path?

getting the same error

try { await extract(file, { dir: "app/my-downloads/es" <====== my folder name where i want the files to extracted }) console.log('Extraction complete') } catch (err) { console.log("Error",err); // handle any errors }

coddojrponce commented 2 years ago

find this code => if (!path.isAbsolute(opts.dir) in extract-zip/index.html and comment it out to use relative path :)

ayushmanchhabra commented 1 year ago

As a workaround I convert the target directory path to absolute path using Node's path.resolve.

Viridian-Inc commented 4 months ago

NPM support for zip unzipping in windows

"postdownload:script:win": "powershell -Command \"$path = (Resolve-Path .).Path + '\_your_relpath'; if (-Not (Test-Path $path)) { New-Item -ItemType Directory -Force -Path $path }; [System.Reflection.Assembly]::LoadWithPartialName('System.IO.Compression.FileSystem'); [System.IO.Compression.ZipFile]::ExtractToDirectory('_zipped_filename.zip', $path); Remove-Item _zipped_filename.zip\"",

"postdownload:script:win": "powershell -Command \"$path = (Resolve-Path .).Path + '\\your_rel_path'; if (-Not (Test-Path $path)) { New-Item -ItemType Directory -Force -Path $path }; [System.Reflection.Assembly]::LoadWithPartialName('System.IO.Compression.FileSystem'); [System.IO.Compression.ZipFile]::ExtractToDirectory('zipped_file_name.zip', $path); Remove-Item zipped_file_name.zip\"",