GithubHelp home page GithubHelp logo

max-mapper / extract-zip Goto Github PK

View Code? Open in Web Editor NEW
386.0 5.0 126.0 1.15 MB

Zip extraction written in pure JavaScript. Extracts a zip into a directory.

License: BSD 2-Clause "Simplified" License

JavaScript 96.14% TypeScript 3.86%

extract-zip's Introduction

extract-zip

Unzip written in pure JavaScript. Extracts a zip into a directory. Available as a library or a command line program.

Uses the yauzl ZIP parser.

NPM Uses JS Standard Style Build Status

Installation

Make sure you have Node 10 or greater installed.

Get the library:

npm install extract-zip --save

Install the command line program:

npm install extract-zip -g

JS API

const extract = require('extract-zip')

async function main () {
  try {
    await extract(source, { dir: target })
    console.log('Extraction complete')
  } catch (err) {
    // handle any errors
  }
}

Options

  • dir (required) - the path to the directory where the extracted files are written
  • defaultDirMode - integer - Directory Mode (permissions), defaults to 0o755
  • defaultFileMode - integer - File Mode (permissions), defaults to 0o644
  • onEntry - function - if present, will be called with (entry, zipfile), entry is every entry from the zip file forwarded from the entry event from yauzl. zipfile is the yauzl instance

Default modes are only used if no permissions are set in the zip file.

CLI Usage

extract-zip foo.zip <targetDirectory>

If not specified, targetDirectory will default to process.cwd().

extract-zip's People

Contributors

aduh95 avatar axelpale avatar brian-mann avatar coreybutler avatar erisds avatar gengjiawen avatar luisfelipesdn12 avatar malept avatar marshallofsound avatar matsnow avatar max-mapper avatar smebberson avatar stefanjudis avatar tcoopman avatar thejoshwolfe avatar voiys avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar

extract-zip's Issues

Setup Travis

Running the tests on travis will help ensure that regressions do not occur and make it easier to contribute (since travis will display if the pr tests pass or not in the pr).

Maintainers wanted

New maintainers are wanted for this module, preferably ones who can triage bugs, approve pull requests, and release new packages in a timely manner. If you'd like to do this, go through the existing issues/pull requests and triage/comment on them, and then add a comment here with your GitHub username and NPM username.

document DEBUG=electron-zip environment variable

Its pretty cool you can do

DEBUG=electron-zip node xyz

to get a console log of electron zip. It helped massively tracking down #15

It would be nice to document it on the readme, it would have saved me some time

Error when extracting GitHub repo archive

Trying to extract a repo archive downloaded from GitHub:

const fs = require("fs");
const got = require("got");
const extract = require("extract-zip");
const pify = require("pify");

got("https://codeload.github.com/maxogden/extract-zip/zip/master", { encoding: null })
.then(res => {
  return pify(fs.writeFile)("master.zip", res.body);
}).then(() => {
  return pify(extract)("master.zip", { dir: process.cwd() });
}).then(() => {
  console.log("Done!");
}).catch(err => {
  console.error(err);
});

Produces the following error:

Error: Callback was already called.
    at /Users/lukehorvat/code/test1/node_modules/async/lib/async.js:30:31
    at WriteStream.<anonymous> (/Users/lukehorvat/code/test1/node_modules/extract-zip/index.js:122:24)
    at emitOne (events.js:82:20)
    at WriteStream.emit (events.js:169:7)
    at WriteStream.<anonymous> (fs.js:1846:12)
    at FSReqWrap.oncomplete (fs.js:82:15)

I decided to print out the error above line 122 and it is as follows:

Error: ENOENT: no such file or directory, open '/Users/lukehorvat/code/test1/extract-zip-master/'

Any idea what's going on here?

Error: EBADF: bad file descriptor, read

Hi, I'm raising this bug a bit early as I'm still in the middle of debugging a pretty serious bug we've discovered in the latest release of Ghost and will update as I go trying to figure out what's happening.

I'm getting an error in [email protected]:

Error: EBADF: bad file descriptor, read

I get a similar error in [email protected]:

~/gscan/node_modules/extract-zip/node_modules/async/lib/async.js:43
            if (fn === null) throw new Error("Callback was already called.");
                             ^

Error: Callback was already called.
    at ~/gscan/node_modules/extract-zip/node_modules/async/lib/async.js:43:36
    at WriteStream.<anonymous> (~/gscan/node_modules/extract-zip/index.js:145:24)
    at emitOne (events.js:82:20)
    at WriteStream.emit (events.js:169:7)
    at WriteStream.<anonymous> (fs.js:1837:12)
    at FSReqWrap.oncomplete (fs.js:82:15)

This happening when extracting a particular zip file. It's not my zip so I can't share it publicly, and I'm still trying to figure out what the discerning factor is with this zip. The tripping factor appears to be a .git folder at the moment.

The first thing I did is upgrade, which gave me a lower level error.

Additionally, what I have done is a) research the error message and determine that it is probably something to do with trying to call .close() on a file descriptor that is already closed and b) write a 50 line version of extract using the example in the README file of the yauzl repository and verify that this does not give me an error.

Therefore, I'm relatively confident I've found a bug, just not sure what it is yet, and wanted to flag it up early in the hope that someone else might have a clue!

This is happening on Node v4.4.7 on my local machine, and also on Ubuntu. It is reproducible when uploading the offending zip to http://gscan.ghost.org. Will be back soon hopefully with a sharable zip that reproduces the error.

/me goes back to debugging...

Invalid non-string/buffer chunk

Hi, I'm getting Invalid non-string/buffer chunk error on any .zip file I've tested.

I'm passing a path to the file, like so

 var extract = require('extract-zip')
 extract('c:\\Builds\\test.zip', {dir:'C:\\Builds'}, (err) => {
      console.log(err);
    })

Any ideas what can go wrong?

empty directories are not created

I download package electron-v0.30.2-darwin-x64.zip from electron repository at https://github.com/atom/electron/releases/tag/v0.28.1

I write the following and execute it with node:

var extract = require('extract-zip')
    extract("electron-v0.30.2-darwin-x64.zip", {dir: "."}, function(err) {
        console.log(err)
    })

It extract these files

โžœ  .electron  ls ~/.node/lib/node_modules/electron-prebuilt/dist/Electron.app/Contents/Resources 
atom.asar   atom.icns   default_app

when it should have extracted these files:

โžœ  .electron  ls Electron.app/Contents/Resources/
am.lproj     bn.lproj     default_app  es_419.lproj fr.lproj     hu.lproj     ko.lproj     ms.lproj     pt_PT.lproj  sr.lproj     th.lproj     zh_TW.lproj
ar.lproj     ca.lproj     el.lproj     et.lproj     gu.lproj     id.lproj     lt.lproj     nb.lproj     ro.lproj     sv.lproj     tr.lproj
atom.asar    cs.lproj     en.lproj     fa.lproj     he.lproj     it.lproj     lv.lproj     nl.lproj     ru.lproj     sw.lproj     uk.lproj
atom.icns    da.lproj     en_GB.lproj  fi.lproj     hi.lproj     ja.lproj     ml.lproj     pl.lproj     sk.lproj     ta.lproj     vi.lproj
bg.lproj     de.lproj     es.lproj     fil.lproj    hr.lproj     kn.lproj     mr.lproj     pt_BR.lproj  sl.lproj     te.lproj     zh_CN.lproj

Shrink dependency graph by pruning Node 4 things

I noticed that GoogleChrome/puppeteer has an indirect dependency on isarray, which is coming in through extract-zip. See https://npm.anvaka.com/#/view/2d/puppeteer/1.11.0.

The chain is:

The latest versions of puppeteer, extract-zip, contact-stream and readable-stream only support Node 6 and above.

  • readable-stream 3.0 no longer depends on isarray.
  • concat-stream 2.0 uses readable-stream 3.0.

The next step is for extract-zip to use concat-stream 2.0, and publish a release.

Relative path not possible anymore ?

Hi,

Thanks for the lib.
I'm using it in an nwjs app to extract to a relative path.
It was working great but now it throws "Target directory is expected to be absolute".

If I just remove

  if (path.isAbsolute(opts.dir) === false) {
    return cb(new Error('Target directory is expected to be absolute'))
  }

it still works so why forbidding relative path ?

Cheers,

Julien

invalid characters in fileName

An error thrown by the yauzl module isn't catched by the extract-zip module, which results in an uncaught exception.

Error: invalid characters in fileName:

Unhandled error event

In case of a bad archive, for example https://search.maven.org/remotecontent?filepath=org/xhtmlrenderer/flying-saucer-pdf-itext5/9.1.12/flying-saucer-pdf-itext5-9.1.12-sources.jar, yauzl library emits an error event which isn't handled. It causes a running process to crash instead of returning an error callback.
Something like the following should be added in index.js:

zipfile.on('error', function (err) {
   return cb(err)
})

Callback called multiple times

I am using the electron-packager module and stumbled into the case that the callback of extract-zip is called multiple time in error case.

The bug is reproducible here https://github.com/stefanjudis/extract-zip-bug-example.

These lines

'use strict';

var extract = require( 'extract-zip' );

extract( __dirname + '/electron-v0.36.2-darwin-x64.zip', { dir : __dirname + '/dist' }, function( error ) {
  console.log( 'Calling with error :' + error );
} );

lead to this output

stefan @ stefan-mac: ~/Sites/extract-zip-bug-example master ใƒพ(โŒโ– _โ– )ใƒŽ
> node index.js
39340031
Calling with error :Error: EEXIST: file already exists, symlink 'Versions/Current/Electron Framework' -> '/Users/stefan/Sites/extract-zip-bug-example/dist/Electron.app/Contents/Frameworks/Electron Framework.framework/Electron Framework'
39340031
Calling with error :undefined

stefan @ stefan-mac: ~/Sites/extract-zip-bug-example master ใƒพ(โŒโ– _โ– )ใƒŽ
> node --version
v5.0.0

add electron mac, linux and windows zips as test cases

#10 was caused by not testing the linux and windows electron zips, we should add them to the test suite. I tested the mac one manually but it should get added too

I don't mind the test suite of this having to download the 100mb+ needed for this issue if it means more stability

I think the tests should extract them, and then test that certain files were created. I'm not sure exactly which files to test yet, but if someone wants to tackle this, just start with something basic

zipfile reference argument in onEntry

It would be useful to have a reference to the underlying yauzl zipfile passed to the onEntry method (in addition to the existing entry). My use case is similar to issue #8, in that I need a pretty detailed progress report.

let extracted = 0

extract(archive, {
  dir: tmpdir,
  onEntry: (entry, zipfile) => {
    extracted++

    EventEmitter.emit('progress', {
      filename: entry.fileName,
      entryNumber: extracted,
      totalEntries: zipfile.entryCount
    })
  }
}, (err) => {
  if (err) {
    throw err
  }

  callback()
})

I use entryNumber/totalEntries to calculate a percentage.

Cannot overwrite existing directory if symlink present (OSX)

Let's say I have x.zip with contains a symlink and I unzip the first time to /foo.
If I try to unzip the same zip (or another zip containing the same symlink) to /foo it will fail with EEXIST. Regular files overwrite as expected (ie fs.writestream by default will overwrite). Unfortunately fs.symlink fails if the symlink already exists.

I can make a PR but do you have any suggestions on how to proceed?
I was thinking we check if the symlink already exists and delete before creating the new symlink.

Furthermore - should overwrite be set by flag (for the regular files as well)?

Fails to extract directories (for some zips)

Noticed here: electron-userland/electron-prebuilt#57 (comment)

Example zip: https://github.com/atom/electron/releases/download/v0.32.3/electron-v0.32.3-linux-x64.zip

This appears to stem from whether a directory is included in the zip's manifest(?).

test/cats.zip

[...]
/tmp/cat-extract-test/cats/
/tmp/cat-extract-test/cats/.DS_Store
/tmp/cat-extract-test/cats/deema3.5771930_std.JPG
/tmp/cat-extract-test/cats/Deema_019.204205705_std.jpg
/tmp/cat-extract-test/cats/empty/
/tmp/cat-extract-test/cats/gJqEYBs.jpg
/tmp/cat-extract-test/cats/orange/
[...]

vs

electron-v0.32.3-linux-x64.zip

[...]
/tmp/elec-extract-test/libgcrypt.so.11
/tmp/elec-extract-test/libnotify.so.4
/tmp/elec-extract-test/resources/atom.asar
[...]

Note the lack of a /tmp/elec-extract-test/resources/.

Add a callback to onEntry that can be used to continue or cancel extraction

I have a need to inspect the contents of an archive and verify that it contains only certain file types.
I can supply an onEntry function in the options passed into extract to inspect the entry and check if it is allowed or not. However I do not see a way to signal back to extract-zip whether the extraction should continue or be cancelled. Ideally I want to use a library such as mmmagic to do deeper inspection where the result is returned in a callback.
It would be very useful if onEntry took a third parameter, a function, that could be called to continue/cancel the extraction.

'fs'dependency not found

Hi,
During using this module, I found that the 'extract-zip/index.js' file require 'fs' module which is no longer existed. So, who can I resolve this issue ?

The same issue happens for its dependency in package.json file is 'rimraf' module :(

__macosx folder

what is it and why is it in zip files. is it supposed to get ignored?

SyntaxError: Octal literals are not allowed in strict mode. [bug]

My node runs by default in strict_mode, how to overcome this bug?

0|GoatSolo | /Users/damz/Desktop/goatsolo/node_modules/extract-zip/node_modules/mkdirp/index.js:19
0|GoatSolo |         mode = 0777 & (~process.umask());
0|GoatSolo |                ^^^^
0|GoatSolo | SyntaxError: Octal literals are not allowed in strict mode.
0|GoatSolo |     at createScript (vm.js:80:10)
0|GoatSolo |     at Object.runInThisContext (vm.js:139:10)
0|GoatSolo |     at Module._compile (module.js:588:28)
0|GoatSolo |     at Object.Module._extensions..js (module.js:635:10)
0|GoatSolo |     at Module.load (module.js:545:32)
0|GoatSolo |     at tryModuleLoad (module.js:508:12)
0|GoatSolo |     at Function.Module._load (module.js:500:3)
0|GoatSolo |     at Module.require (module.js:568:17)
0|GoatSolo |     at require (internal/module.js:11:18)
0|GoatSolo |     at Object.<anonymous> (/Users/damz/Desktop/goatsolo/node_modules/extract-zip/index.js:4:14)

Error: EEXIST: file already exists, mkdir

error! { Error: EEXIST: file already exists, mkdir 'C:\abc\hhdhd\ddd\fff\www\klks\qsqsqs\a.b.i\D.P.data'
errno: -4075,
code: 'EEXIST',
syscall: 'mkdir',
path: 'C:\abc\hhdhd\ddd\fff\www\klks\qsqsqs\a.b.i\D.P.data' }

files set to read only

When I extract a zip, the folder gets read/write but the files inside it get read only permissions. Is there a way to set them all to read/write?

ENOENT with International characters on windows...

2017-06-05T16:25:53-07:00 - error: Problems unzipping file : test.zip, err: Error: ENOENT: no such file or directory, open 'C:\Users\ADMINI~1\AppData\Local\Temp\2\Qura
ุง ู…ุญู…ูˆุฏ ุงู„ุญุณู†.txt'

Progress of overall extraction.

I am using this module in a game launcher/patcher.

I would like to implement a way to get the current file being extracted and overall progress of an extraction operation, from what I can tell the zip parser is quite nice.

Im just thinking of doing a fork and adding this as an extra option.
Thought I would post here in-case there are any guidelines or gotchas someone might recommend.

Would use an event emitter to notify about the current status and progress.
Time permitting I will do this soon.

Thanks for the wrapper :).

[BUG] Files created in readonly - Callback already called + write error on next write.

Please keep in mind that I am trying this on an older Node Webkit 0.12.0 on Windows XP, 7, 8, 10.
Seems I have to use this version for windows XP support but its node version is higher than the required one for this module.

write error Objecterror: Errorcode: "EPERM"errno: -4048message: "EPERM: operation not permitted, open 'E:\TEST\gfdsgasd\TEST.txt'"path: "E:\TEST\gfdsgasd\TEST.txt"

My zip file contains a text file that is it.

The odd thing is when I goto the file on disk it is there but empty (probably from a previous attempt)
I deleted everything and ran again and it worked which indicates it can't overwrite existing files or directories.

DOH Its creating the file in read only mode. When I zipped the file it was not read only so the permission is being incorrectly set on here.

Ah here is a fix
Line 67-71 of extract-zip/index.js

// if no mode then use the default.
if (mode === 0) {
  if (isDir) mode = 0555
  else mode = 0666 //mode = 0444 read only
}

Maybe there should have a way to specify the default mode if none is set?
Although if I am extracting a file from a ZIP I would kind of expect it to default to writable at least for my user and createWriteStream + other file write methods default to 0666 so I think that should be the default.

What are your thoughts on this?

Sample code

extractZip(path, { dir: 'E:\\TEST' }, function(err) {
    console.log('extracted', err);
});

Invalid code lengths set

Got this error while unzipping. The problem is that I can't handle it.

Sample:

try {
    var extract = require('extract-zip');
    extract('bad.zip', { dir: '.' }, function (err) {
        console.log('Error: ' + err);
    });
} catch (err) {
    console.log('Catch: ' + err);
}

Console output:

$ node test.js
read err { [Error: invalid code lengths set] errno: -3, code: 'Z_DATA_ERROR' }

Bad zip: https://www.dropbox.com/s/chqml0p17h7li62/bad.zip?dl=0

node: 5.9.1
npm: 3.7.3

Regression between 1.6.0 and 1.6.1 with directories in zips

We've noticed a regression in extract-zip when trying to npm install electron.

This line fails with this error (ran the file manually, to see which version caused the regression):

Error: ENOENT: no such file or directory, lstat '/tmp/electron-prebuilt/dist/resources'

When the script fails, I noticed that neither folder (resources or locales) were in the extracted folder. My guess is that it's not recursively creating subfolders correctly.

See also: electron/electron#9323

Why not relative path?

I tried to comment these lines of code:
/*if (path.isAbsolute(opts.dir) === false) { return cb(new Error('Target directory is expected to be absolute')) }*/
and if i put a relative path for target directory it works good (i need this).
Why is it possible to put only absolute path for target directory?

Error: EISDIR: illegal operation on a directory

Hi,

I m getting an error while extracting a zip file, probably made on windows, i m unsure as it s not mine, but believe so as it s about a windows binary.

The file seems not corrupted as i can unzip it with gnome unzip app.

Please see the debug output, and a test code to reproduce the error,

File downloaded at /home/mh-cbon/projects/nssm-prebuilt/dl.zip
Unzipping to /home/mh-cbon/projects/nssm-prebuilt/prebuilt
  extract-zip creating target directory +0ms /home/mh-cbon/projects/nssm-prebuilt/prebuilt
  extract-zip opening +2ms /home/mh-cbon/projects/nssm-prebuilt/dl.zip with opts { dir: '/home/mh-cbon/projects/nssm-prebuilt/prebuilt' }
  extract-zip zipfile entry +6ms nssm-2.24/
  extract-zip extracting entry +0ms { filename: 'nssm-2.24/', isDir: true, isSymlink: false }
  extract-zip mkdirp +0ms { dir: '/home/mh-cbon/projects/nssm-prebuilt/prebuilt/nssm-2.24/' }
  extract-zip finished processing +1ms nssm-2.24/
  extract-zip zipfile entry +1ms nssm-2.24/ChangeLog.txt
  extract-zip extracting entry +0ms { filename: 'nssm-2.24/ChangeLog.txt',
  isDir: false,
  isSymlink: false }
  extract-zip mkdirp +0ms { dir: '/home/mh-cbon/projects/nssm-prebuilt/prebuilt/nssm-2.24' }
  extract-zip opening read stream +0ms /home/mh-cbon/projects/nssm-prebuilt/prebuilt/nssm-2.24/ChangeLog.txt
  extract-zip finished processing +11ms nssm-2.24/ChangeLog.txt
  extract-zip zipfile entry +0ms nssm-2.24/README.txt
  extract-zip extracting entry +0ms { filename: 'nssm-2.24/README.txt',
  isDir: false,
  isSymlink: false }
  extract-zip mkdirp +0ms { dir: '/home/mh-cbon/projects/nssm-prebuilt/prebuilt/nssm-2.24' }
  extract-zip opening read stream +1ms /home/mh-cbon/projects/nssm-prebuilt/prebuilt/nssm-2.24/README.txt
  extract-zip finished processing +2ms nssm-2.24/README.txt
  extract-zip zipfile entry +0ms nssm-2.24/src/
  extract-zip extracting entry +0ms { filename: 'nssm-2.24/src/', isDir: true, isSymlink: false }
  extract-zip mkdirp +1ms { dir: '/home/mh-cbon/projects/nssm-prebuilt/prebuilt/nssm-2.24/src/' }
  extract-zip finished processing +0ms nssm-2.24/src/
  extract-zip zipfile entry +0ms nssm-2.24/src/account.cpp
  extract-zip extracting entry +0ms { filename: 'nssm-2.24/src/account.cpp',
  isDir: false,
  isSymlink: false }
  extract-zip mkdirp +0ms { dir: '/home/mh-cbon/projects/nssm-prebuilt/prebuilt/nssm-2.24/src' }
  extract-zip opening read stream +1ms /home/mh-cbon/projects/nssm-prebuilt/prebuilt/nssm-2.24/src/account.cpp
  extract-zip finished processing +1ms nssm-2.24/src/account.cpp
  extract-zip zipfile entry +1ms nssm-2.24/src/account.h
  extract-zip extracting entry +1ms { filename: 'nssm-2.24/src/account.h',
  isDir: false,
  isSymlink: false }
  extract-zip mkdirp +0ms { dir: '/home/mh-cbon/projects/nssm-prebuilt/prebuilt/nssm-2.24/src' }
  extract-zip opening read stream +1ms /home/mh-cbon/projects/nssm-prebuilt/prebuilt/nssm-2.24/src/account.h
  extract-zip finished processing +2ms nssm-2.24/src/account.h
  extract-zip zipfile entry +1ms nssm-2.24/src/console.cpp
  extract-zip extracting entry +0ms { filename: 'nssm-2.24/src/console.cpp',
  isDir: false,
  isSymlink: false }
  extract-zip mkdirp +0ms { dir: '/home/mh-cbon/projects/nssm-prebuilt/prebuilt/nssm-2.24/src' }
  extract-zip opening read stream +0ms /home/mh-cbon/projects/nssm-prebuilt/prebuilt/nssm-2.24/src/console.cpp
  extract-zip finished processing +0ms nssm-2.24/src/console.cpp
  extract-zip zipfile entry +1ms nssm-2.24/src/console.h
  extract-zip extracting entry +0ms { filename: 'nssm-2.24/src/console.h',
  isDir: false,
  isSymlink: false }
  extract-zip mkdirp +1ms { dir: '/home/mh-cbon/projects/nssm-prebuilt/prebuilt/nssm-2.24/src' }
  extract-zip opening read stream +0ms /home/mh-cbon/projects/nssm-prebuilt/prebuilt/nssm-2.24/src/console.h
  extract-zip finished processing +1ms nssm-2.24/src/console.h
  extract-zip zipfile entry +1ms nssm-2.24/src/env.cpp
  extract-zip extracting entry +0ms { filename: 'nssm-2.24/src/env.cpp',
  isDir: false,
  isSymlink: false }
  extract-zip mkdirp +0ms { dir: '/home/mh-cbon/projects/nssm-prebuilt/prebuilt/nssm-2.24/src' }
  extract-zip opening read stream +0ms /home/mh-cbon/projects/nssm-prebuilt/prebuilt/nssm-2.24/src/env.cpp
  extract-zip finished processing +1ms nssm-2.24/src/env.cpp
  extract-zip zipfile entry +1ms nssm-2.24/src/env.h
  extract-zip extracting entry +0ms { filename: 'nssm-2.24/src/env.h',
  isDir: false,
  isSymlink: false }
  extract-zip mkdirp +0ms { dir: '/home/mh-cbon/projects/nssm-prebuilt/prebuilt/nssm-2.24/src' }
  extract-zip opening read stream +1ms /home/mh-cbon/projects/nssm-prebuilt/prebuilt/nssm-2.24/src/env.h
  extract-zip finished processing +2ms nssm-2.24/src/env.h
  extract-zip zipfile entry +0ms nssm-2.24/src/event.cpp
  extract-zip extracting entry +0ms { filename: 'nssm-2.24/src/event.cpp',
  isDir: false,
  isSymlink: false }
  extract-zip mkdirp +0ms { dir: '/home/mh-cbon/projects/nssm-prebuilt/prebuilt/nssm-2.24/src' }
  extract-zip opening read stream +1ms /home/mh-cbon/projects/nssm-prebuilt/prebuilt/nssm-2.24/src/event.cpp
  extract-zip finished processing +0ms nssm-2.24/src/event.cpp
  extract-zip zipfile entry +0ms nssm-2.24/src/event.h
  extract-zip extracting entry +0ms { filename: 'nssm-2.24/src/event.h',
  isDir: false,
  isSymlink: false }
  extract-zip mkdirp +0ms { dir: '/home/mh-cbon/projects/nssm-prebuilt/prebuilt/nssm-2.24/src' }
  extract-zip opening read stream +1ms /home/mh-cbon/projects/nssm-prebuilt/prebuilt/nssm-2.24/src/event.h
  extract-zip finished processing +0ms nssm-2.24/src/event.h
  extract-zip zipfile entry +0ms nssm-2.24/src/gui.cpp
  extract-zip extracting entry +0ms { filename: 'nssm-2.24/src/gui.cpp',
  isDir: false,
  isSymlink: false }
  extract-zip mkdirp +0ms { dir: '/home/mh-cbon/projects/nssm-prebuilt/prebuilt/nssm-2.24/src' }
  extract-zip opening read stream +1ms /home/mh-cbon/projects/nssm-prebuilt/prebuilt/nssm-2.24/src/gui.cpp
  extract-zip finished processing +0ms nssm-2.24/src/gui.cpp
  extract-zip zipfile entry +1ms nssm-2.24/src/gui.h
  extract-zip extracting entry +0ms { filename: 'nssm-2.24/src/gui.h',
  isDir: false,
  isSymlink: false }
  extract-zip mkdirp +1ms { dir: '/home/mh-cbon/projects/nssm-prebuilt/prebuilt/nssm-2.24/src' }
  extract-zip opening read stream +1ms /home/mh-cbon/projects/nssm-prebuilt/prebuilt/nssm-2.24/src/gui.h
  extract-zip finished processing +0ms nssm-2.24/src/gui.h
  extract-zip zipfile entry +1ms nssm-2.24/src/imports.cpp
  extract-zip extracting entry +0ms { filename: 'nssm-2.24/src/imports.cpp',
  isDir: false,
  isSymlink: false }
  extract-zip mkdirp +0ms { dir: '/home/mh-cbon/projects/nssm-prebuilt/prebuilt/nssm-2.24/src' }
  extract-zip opening read stream +0ms /home/mh-cbon/projects/nssm-prebuilt/prebuilt/nssm-2.24/src/imports.cpp
  extract-zip finished processing +1ms nssm-2.24/src/imports.cpp
  extract-zip zipfile entry +1ms nssm-2.24/src/imports.h
  extract-zip extracting entry +0ms { filename: 'nssm-2.24/src/imports.h',
  isDir: false,
  isSymlink: false }
  extract-zip mkdirp +0ms { dir: '/home/mh-cbon/projects/nssm-prebuilt/prebuilt/nssm-2.24/src' }
  extract-zip opening read stream +0ms /home/mh-cbon/projects/nssm-prebuilt/prebuilt/nssm-2.24/src/imports.h
  extract-zip finished processing +1ms nssm-2.24/src/imports.h
  extract-zip zipfile entry +3ms nssm-2.24/src/io.cpp
  extract-zip extracting entry +1ms { filename: 'nssm-2.24/src/io.cpp',
  isDir: false,
  isSymlink: false }
  extract-zip mkdirp +1ms { dir: '/home/mh-cbon/projects/nssm-prebuilt/prebuilt/nssm-2.24/src' }
  extract-zip opening read stream +2ms /home/mh-cbon/projects/nssm-prebuilt/prebuilt/nssm-2.24/src/io.cpp
  extract-zip finished processing +3ms nssm-2.24/src/io.cpp
  extract-zip zipfile entry +0ms nssm-2.24/src/io.h
  extract-zip extracting entry +1ms { filename: 'nssm-2.24/src/io.h',
  isDir: false,
  isSymlink: false }
  extract-zip mkdirp +0ms { dir: '/home/mh-cbon/projects/nssm-prebuilt/prebuilt/nssm-2.24/src' }
  extract-zip opening read stream +0ms /home/mh-cbon/projects/nssm-prebuilt/prebuilt/nssm-2.24/src/io.h
  extract-zip finished processing +1ms nssm-2.24/src/io.h
  extract-zip zipfile entry +1ms nssm-2.24/src/messages.mc
  extract-zip extracting entry +0ms { filename: 'nssm-2.24/src/messages.mc',
  isDir: false,
  isSymlink: false }
  extract-zip mkdirp +0ms { dir: '/home/mh-cbon/projects/nssm-prebuilt/prebuilt/nssm-2.24/src' }
  extract-zip opening read stream +0ms /home/mh-cbon/projects/nssm-prebuilt/prebuilt/nssm-2.24/src/messages.mc
  extract-zip finished processing +5ms nssm-2.24/src/messages.mc
  extract-zip zipfile entry +0ms nssm-2.24/src/nssm.cpp
  extract-zip extracting entry +0ms { filename: 'nssm-2.24/src/nssm.cpp',
  isDir: false,
  isSymlink: false }
  extract-zip mkdirp +1ms { dir: '/home/mh-cbon/projects/nssm-prebuilt/prebuilt/nssm-2.24/src' }
  extract-zip opening read stream +0ms /home/mh-cbon/projects/nssm-prebuilt/prebuilt/nssm-2.24/src/nssm.cpp
  extract-zip finished processing +1ms nssm-2.24/src/nssm.cpp
  extract-zip zipfile entry +0ms nssm-2.24/src/nssm.h
  extract-zip extracting entry +0ms { filename: 'nssm-2.24/src/nssm.h',
  isDir: false,
  isSymlink: false }
  extract-zip mkdirp +0ms { dir: '/home/mh-cbon/projects/nssm-prebuilt/prebuilt/nssm-2.24/src' }
  extract-zip opening read stream +1ms /home/mh-cbon/projects/nssm-prebuilt/prebuilt/nssm-2.24/src/nssm.h
  extract-zip finished processing +0ms nssm-2.24/src/nssm.h
  extract-zip zipfile entry +0ms nssm-2.24/src/nssm.ico
  extract-zip extracting entry +0ms { filename: 'nssm-2.24/src/nssm.ico',
  isDir: false,
  isSymlink: false }
  extract-zip mkdirp +1ms { dir: '/home/mh-cbon/projects/nssm-prebuilt/prebuilt/nssm-2.24/src' }
  extract-zip opening read stream +0ms /home/mh-cbon/projects/nssm-prebuilt/prebuilt/nssm-2.24/src/nssm.ico
  extract-zip finished processing +1ms nssm-2.24/src/nssm.ico
  extract-zip zipfile entry +1ms nssm-2.24/src/nssm.rc
  extract-zip extracting entry +0ms { filename: 'nssm-2.24/src/nssm.rc',
  isDir: false,
  isSymlink: false }
  extract-zip mkdirp +0ms { dir: '/home/mh-cbon/projects/nssm-prebuilt/prebuilt/nssm-2.24/src' }
  extract-zip opening read stream +0ms /home/mh-cbon/projects/nssm-prebuilt/prebuilt/nssm-2.24/src/nssm.rc
  extract-zip finished processing +2ms nssm-2.24/src/nssm.rc
  extract-zip zipfile entry +0ms nssm-2.24/src/nssm.sln
  extract-zip extracting entry +0ms { filename: 'nssm-2.24/src/nssm.sln',
  isDir: false,
  isSymlink: false }
  extract-zip mkdirp +0ms { dir: '/home/mh-cbon/projects/nssm-prebuilt/prebuilt/nssm-2.24/src' }
  extract-zip opening read stream +1ms /home/mh-cbon/projects/nssm-prebuilt/prebuilt/nssm-2.24/src/nssm.sln
  extract-zip finished processing +2ms nssm-2.24/src/nssm.sln
  extract-zip zipfile entry +1ms nssm-2.24/src/nssm.vcproj
  extract-zip extracting entry +0ms { filename: 'nssm-2.24/src/nssm.vcproj',
  isDir: false,
  isSymlink: false }
  extract-zip mkdirp +0ms { dir: '/home/mh-cbon/projects/nssm-prebuilt/prebuilt/nssm-2.24/src' }
  extract-zip opening read stream +0ms /home/mh-cbon/projects/nssm-prebuilt/prebuilt/nssm-2.24/src/nssm.vcproj
  extract-zip finished processing +1ms nssm-2.24/src/nssm.vcproj
  extract-zip zipfile entry +0ms nssm-2.24/src/process.cpp
  extract-zip extracting entry +0ms { filename: 'nssm-2.24/src/process.cpp',
  isDir: false,
  isSymlink: false }
  extract-zip mkdirp +0ms { dir: '/home/mh-cbon/projects/nssm-prebuilt/prebuilt/nssm-2.24/src' }
  extract-zip opening read stream +0ms /home/mh-cbon/projects/nssm-prebuilt/prebuilt/nssm-2.24/src/process.cpp
  extract-zip finished processing +1ms nssm-2.24/src/process.cpp
  extract-zip zipfile entry +0ms nssm-2.24/src/process.h
  extract-zip extracting entry +0ms { filename: 'nssm-2.24/src/process.h',
  isDir: false,
  isSymlink: false }
  extract-zip mkdirp +0ms { dir: '/home/mh-cbon/projects/nssm-prebuilt/prebuilt/nssm-2.24/src' }
  extract-zip opening read stream +1ms /home/mh-cbon/projects/nssm-prebuilt/prebuilt/nssm-2.24/src/process.h
  extract-zip finished processing +0ms nssm-2.24/src/process.h
  extract-zip zipfile entry +1ms nssm-2.24/src/registry.cpp
  extract-zip extracting entry +0ms { filename: 'nssm-2.24/src/registry.cpp',
  isDir: false,
  isSymlink: false }
  extract-zip mkdirp +0ms { dir: '/home/mh-cbon/projects/nssm-prebuilt/prebuilt/nssm-2.24/src' }
  extract-zip opening read stream +0ms /home/mh-cbon/projects/nssm-prebuilt/prebuilt/nssm-2.24/src/registry.cpp
  extract-zip finished processing +1ms nssm-2.24/src/registry.cpp
  extract-zip zipfile entry +0ms nssm-2.24/src/registry.h
  extract-zip extracting entry +0ms { filename: 'nssm-2.24/src/registry.h',
  isDir: false,
  isSymlink: false }
  extract-zip mkdirp +0ms { dir: '/home/mh-cbon/projects/nssm-prebuilt/prebuilt/nssm-2.24/src' }
  extract-zip opening read stream +0ms /home/mh-cbon/projects/nssm-prebuilt/prebuilt/nssm-2.24/src/registry.h
  extract-zip finished processing +0ms nssm-2.24/src/registry.h
  extract-zip zipfile entry +1ms nssm-2.24/src/resource.h
  extract-zip extracting entry +0ms { filename: 'nssm-2.24/src/resource.h',
  isDir: false,
  isSymlink: false }
  extract-zip mkdirp +0ms { dir: '/home/mh-cbon/projects/nssm-prebuilt/prebuilt/nssm-2.24/src' }
  extract-zip opening read stream +0ms /home/mh-cbon/projects/nssm-prebuilt/prebuilt/nssm-2.24/src/resource.h
  extract-zip finished processing +0ms nssm-2.24/src/resource.h
  extract-zip zipfile entry +0ms nssm-2.24/src/service.cpp
  extract-zip extracting entry +0ms { filename: 'nssm-2.24/src/service.cpp',
  isDir: false,
  isSymlink: false }
  extract-zip mkdirp +0ms { dir: '/home/mh-cbon/projects/nssm-prebuilt/prebuilt/nssm-2.24/src' }
  extract-zip opening read stream +0ms /home/mh-cbon/projects/nssm-prebuilt/prebuilt/nssm-2.24/src/service.cpp
  extract-zip finished processing +1ms nssm-2.24/src/service.cpp
  extract-zip zipfile entry +1ms nssm-2.24/src/service.h
  extract-zip extracting entry +0ms { filename: 'nssm-2.24/src/service.h',
  isDir: false,
  isSymlink: false }
  extract-zip mkdirp +0ms { dir: '/home/mh-cbon/projects/nssm-prebuilt/prebuilt/nssm-2.24/src' }
  extract-zip opening read stream +0ms /home/mh-cbon/projects/nssm-prebuilt/prebuilt/nssm-2.24/src/service.h
  extract-zip finished processing +3ms nssm-2.24/src/service.h
  extract-zip zipfile entry +1ms nssm-2.24/src/settings.cpp
  extract-zip extracting entry +1ms { filename: 'nssm-2.24/src/settings.cpp',
  isDir: false,
  isSymlink: false }
  extract-zip mkdirp +1ms { dir: '/home/mh-cbon/projects/nssm-prebuilt/prebuilt/nssm-2.24/src' }
  extract-zip opening read stream +1ms /home/mh-cbon/projects/nssm-prebuilt/prebuilt/nssm-2.24/src/settings.cpp
  extract-zip finished processing +1ms nssm-2.24/src/settings.cpp
  extract-zip zipfile entry +1ms nssm-2.24/src/settings.h
  extract-zip extracting entry +0ms { filename: 'nssm-2.24/src/settings.h',
  isDir: false,
  isSymlink: false }
  extract-zip mkdirp +0ms { dir: '/home/mh-cbon/projects/nssm-prebuilt/prebuilt/nssm-2.24/src' }
  extract-zip opening read stream +0ms /home/mh-cbon/projects/nssm-prebuilt/prebuilt/nssm-2.24/src/settings.h
  extract-zip finished processing +1ms nssm-2.24/src/settings.h
  extract-zip zipfile entry +0ms nssm-2.24/src/version.cmd
  extract-zip extracting entry +0ms { filename: 'nssm-2.24/src/version.cmd',
  isDir: false,
  isSymlink: false }
  extract-zip mkdirp +0ms { dir: '/home/mh-cbon/projects/nssm-prebuilt/prebuilt/nssm-2.24/src' }
  extract-zip opening read stream +0ms /home/mh-cbon/projects/nssm-prebuilt/prebuilt/nssm-2.24/src/version.cmd
  extract-zip finished processing +0ms nssm-2.24/src/version.cmd
  extract-zip zipfile entry +1ms nssm-2.24/win32/
  extract-zip extracting entry +0ms { filename: 'nssm-2.24/win32/', isDir: false, isSymlink: false }
  extract-zip mkdirp +0ms { dir: '/home/mh-cbon/projects/nssm-prebuilt/prebuilt/nssm-2.24' }
  extract-zip opening read stream +0ms /home/mh-cbon/projects/nssm-prebuilt/prebuilt/nssm-2.24/win32/
  extract-zip finished processing +0ms nssm-2.24/win32/
  extract-zip write error +1ms { error: 
   { [Error: EISDIR: illegal operation on a directory, open '/home/mh-cbon/projects/nssm-prebuilt/prebuilt/nssm-2.24/win32/']
     errno: -21,
     code: 'EISDIR',
     syscall: 'open',
     path: '/home/mh-cbon/projects/nssm-prebuilt/prebuilt/nssm-2.24/win32/' } }
Error: EISDIR: illegal operation on a directory, open '/home/mh-cbon/projects/nssm-prebuilt/prebuilt/nssm-2.24/win32/'
    at Error (native)
/home/mh-cbon/projects/nssm-prebuilt/install.js:64
    throw err
    ^

Error: EISDIR: illegal operation on a directory, open '/home/mh-cbon/projects/nssm-prebuilt/prebuilt/nssm-2.24/win32/'
    at Error (native)

test code from this repo https://github.com/mh-cbon/nssm-prebuilt

var pkg         = require('./package.json')
var hyperquest  = require('hyperquest')
var extract     = require('extract-zip')
var path        = require('path');
var async       = require('async');
var fs          = require('fs');
var Spinner     = require('cli-spinner').Spinner;


var url         = pkg["x-url"] || "https://nssm.cc/release/nssm-2.24.zip";
var dlFile      = path.join(__dirname, "dl.zip")
var targetPath  = path.join(__dirname, "prebuilt")


var downloadFile = function (then) {

  fs.access(dlFile, fs.F_OK, function (err) {

    if (!err) {
      console.log("File already downloaded at %s", dlFile)
      return then()
    }

    console.log("Downloading %s to %s", url, dlFile)
    var spinner = new Spinner('please wait.. %s');
    spinner.setSpinnerString('|/-\\');
    spinner.start();

    var r = hyperquest(url);
    r.pipe(fs.createWriteStream(dlFile));
    r.on('error', function (err) {
      spinner.stop(true);
      then(err)
    })
    r.on('end', function () {
      spinner.stop(true);
      then()
    });
  });

}

var createUnzipDir = function (then) {
  fs.access(dlFile, fs.F_OK, function (err) {
    if(err) fs.mkdir(targetPath, then)
    else then()
  })
}

var unzipfile = function (then) {
  console.log("Unzipping to %s", targetPath)
  extract(dlFile, {dir: targetPath}, then)
}

async.series([
    downloadFile,
    createUnzipDir,
    unzipfile
], function (err) {
  if (err) {
    console.error(err.stack)
    throw err
  }
  console.log("All done !")
});

It seems to be related to #13

I hope you can take a moment to help me !

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.