Comparing version 3.1.1 to 3.1.2
@@ -8,3 +8,3 @@ #!/usr/bin/env node | ||
const glob = require('glob'); | ||
const argv = process.argv; | ||
const {argv} = process; | ||
@@ -20,4 +20,4 @@ const args = require('yargs-parser')(argv.slice(2), { | ||
p: 'pack', | ||
x: 'extract' | ||
} | ||
x: 'extract', | ||
}, | ||
}); | ||
@@ -36,3 +36,3 @@ | ||
else if (args.extract) | ||
getName(args.extract, (name) => { | ||
getName(args.extract, (name) => { | ||
main('extract', name); | ||
@@ -45,9 +45,10 @@ }); | ||
const cwd = process.cwd(); | ||
let to, packer; | ||
let to; | ||
let packer; | ||
switch(operation) { | ||
case 'pack': | ||
to = path.join(cwd, file + '.zip'); | ||
packer = onezip.pack(cwd, to, [ | ||
file | ||
to = path.join(cwd, file + '.zip'); | ||
packer = onezip.pack(cwd, to, [ | ||
file, | ||
]); | ||
@@ -58,4 +59,4 @@ | ||
case 'extract': | ||
to = cwd; | ||
packer = onezip.extract(file, to); | ||
to = cwd; | ||
packer = onezip.extract(file, to); | ||
break; | ||
@@ -100,9 +101,9 @@ } | ||
const usage = `Usage: ${info().name} [path]`; | ||
console.log(usage); | ||
console.log('Options:'); | ||
Object.keys(bin).forEach((name) => { | ||
for (const name of Object.keys(bin)) { | ||
console.log(` ${name} ${bin[name]}`); | ||
}); | ||
} | ||
} | ||
@@ -113,10 +114,10 @@ | ||
Object.keys(args).forEach((cmd) => { | ||
for (const cmd of Object.keys(args)) { | ||
if (!cmdReg.test(cmd)) { | ||
const name = info().name; | ||
const {name} = info(); | ||
console.error(`'${cmd}' is not a ${name} option. See '${name} --help'.`); | ||
process.exit(-1); | ||
} | ||
}); | ||
} | ||
} | ||
@@ -21,9 +21,8 @@ 'use strict'; | ||
const _stat = promisify(fs.stat); | ||
const _pipe = promisify(pipe); | ||
inherits(OneZip, EventEmitter); | ||
module.exports = onezip; | ||
module.exports.pack = onezip('pack'); | ||
module.exports.extract = onezip('extract'); | ||
module.exports = onezip; | ||
module.exports.pack = onezip('pack'); | ||
module.exports.extract = onezip('extract'); | ||
@@ -58,9 +57,9 @@ function check(from, to, files) { | ||
EventEmitter.call(this); | ||
this._i = 0; | ||
this._n = 0; | ||
this._i = 0; | ||
this._n = 0; | ||
this._percent = 0; | ||
this._percentPrev = 0; | ||
this._percent = 0; | ||
this._percentPrev = 0; | ||
this._names = []; | ||
this._names = []; | ||
@@ -109,7 +108,7 @@ switch(operation) { | ||
files.forEach((name) => { | ||
for (const name of files) { | ||
const full = path.join(from, name); | ||
this._findFiles(full, fn); | ||
}); | ||
} | ||
}; | ||
@@ -176,3 +175,3 @@ | ||
const [errorPipe] = await tryToCatch(_pipe, [ | ||
const [errorPipe] = await tryToCatch(pipe, [ | ||
zipfile.outputStream, | ||
@@ -184,3 +183,3 @@ streamFile, | ||
return this.emit('error', errorPipe); | ||
if (!this._abort) | ||
@@ -257,3 +256,3 @@ return this.emit('end'); | ||
zipfile.on('entry', (entry) => { | ||
const fileName = entry.fileName; | ||
const {fileName} = entry; | ||
const fn = (error) => { | ||
@@ -273,4 +272,5 @@ if (error) | ||
zipfile.openReadStream(entry, this._onOpenReadStream((readStream) => { | ||
this._writeFile(name, readStream, fn); | ||
zipfile.openReadStream(entry, this._onOpenReadStream(async (readStream) => { | ||
const [e] = await tryToCatch(this._writeFile, name, readStream); | ||
fn(e); | ||
})); | ||
@@ -285,9 +285,9 @@ }); | ||
OneZip.prototype._writeFile = function(fileName, readStream, fn) { | ||
OneZip.prototype._writeFile = async (fileName, readStream) => { | ||
const writeStream = fs.createWriteStream(fileName); | ||
pipe([readStream, writeStream], fn); | ||
await pipe([readStream, writeStream]); | ||
}; | ||
OneZip.prototype._progress = function() { | ||
OneZip.prototype._progress = function() { | ||
++this._i; | ||
@@ -294,0 +294,0 @@ |
{ | ||
"name": "onezip", | ||
"version": "3.1.1", | ||
"version": "3.1.2", | ||
"description": "pack and extract .zip archives with emitter", | ||
@@ -10,11 +10,10 @@ "main": "lib/onezip.js", | ||
"scripts": { | ||
"lint:eslint": "eslint lib", | ||
"lint:eslint:bin": "eslint bin --config .eslint-bin.rc", | ||
"lint": "redrun lint:*", | ||
"test": "tape 'test/**/*.js'", | ||
"coverage": "nyc npm test", | ||
"report": "nyc report --reporter=text-lcov | coveralls", | ||
"watcher": "nodemon -w test -w lib --exec", | ||
"watch:test": "npm run watcher -- npm test", | ||
"watch:coverage": "npm run watcher -- npm run coverage" | ||
"lint": "madrun lint", | ||
"fix:lint": "madrun fix:lint", | ||
"test": "madrun test", | ||
"coverage": "madrun coverage", | ||
"report": "madrun report", | ||
"watcher": "madrun watcher", | ||
"watch:test": "madrun watch:test", | ||
"watch:coverage": "madrun watch:coverage" | ||
}, | ||
@@ -25,5 +24,5 @@ "dependencies": { | ||
"mkdirp": "^0.5.1", | ||
"pipe-io": "^3.0.0", | ||
"pipe-io": "^4.0.0", | ||
"try-to-catch": "^1.0.2", | ||
"yargs-parser": "^11.0.0", | ||
"yargs-parser": "^14.0.0", | ||
"yauzl": "^2.6.0", | ||
@@ -34,9 +33,13 @@ "yazl": "^2.4.1" | ||
"coveralls": "^3.0.0", | ||
"eslint": "^5.6.0", | ||
"eslint": "^6.4.0", | ||
"eslint-plugin-node": "^10.0.0", | ||
"eslint-plugin-putout": "^2.0.0", | ||
"madrun": "^3.0.3", | ||
"mock-require": "^3.0.2", | ||
"nodemon": "^1.11.0", | ||
"nyc": "^13.0.1", | ||
"nyc": "^14.1.1", | ||
"putout": "^6.0.0", | ||
"redrun": "^7.0.0", | ||
"rimraf": "^2.5.4", | ||
"tape": "^4.6.2" | ||
"rimraf": "^3.0.0", | ||
"supertape": "^1.2.3" | ||
}, | ||
@@ -43,0 +46,0 @@ "engines": { |
Sorry, the diff of this file is not supported yet
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
18072
333
12
+ Addedpipe-io@4.0.1(transitive)
+ Addedyargs-parser@14.0.0(transitive)
- Removedpipe-io@3.0.12(transitive)
- Removedyargs-parser@11.1.1(transitive)
Updatedpipe-io@^4.0.0
Updatedyargs-parser@^14.0.0