diff options
| author | Arman Shah <[email protected]> | 2018-02-19 23:50:04 -0800 |
|---|---|---|
| committer | Arman Shah <[email protected]> | 2018-02-19 23:50:04 -0800 |
| commit | ae34dcfd3823a609ba7182f2d6eda593be876f7d (patch) | |
| tree | b9d7f2884c4999349418cbdc4f9ab46d113e0afd /node_modules/extract-zip | |
| parent | Initial commit (diff) | |
| download | launcher-ae34dcfd3823a609ba7182f2d6eda593be876f7d.tar.xz launcher-ae34dcfd3823a609ba7182f2d6eda593be876f7d.zip | |
add base files
Diffstat (limited to 'node_modules/extract-zip')
| -rw-r--r-- | node_modules/extract-zip/.npmignore | 1 | ||||
| -rw-r--r-- | node_modules/extract-zip/.travis.yml | 7 | ||||
| -rw-r--r-- | node_modules/extract-zip/CONTRIBUTING.md | 1 | ||||
| -rw-r--r-- | node_modules/extract-zip/LICENSE | 23 | ||||
| -rwxr-xr-x | node_modules/extract-zip/cli.js | 20 | ||||
| -rw-r--r-- | node_modules/extract-zip/index.js | 205 | ||||
| -rw-r--r-- | node_modules/extract-zip/package.json | 69 | ||||
| -rw-r--r-- | node_modules/extract-zip/readme.md | 49 |
8 files changed, 375 insertions, 0 deletions
diff --git a/node_modules/extract-zip/.npmignore b/node_modules/extract-zip/.npmignore new file mode 100644 index 0000000..b59f7e3 --- /dev/null +++ b/node_modules/extract-zip/.npmignore @@ -0,0 +1 @@ +test/
\ No newline at end of file diff --git a/node_modules/extract-zip/.travis.yml b/node_modules/extract-zip/.travis.yml new file mode 100644 index 0000000..c8ae71a --- /dev/null +++ b/node_modules/extract-zip/.travis.yml @@ -0,0 +1,7 @@ +sudo: false +language: node_js +node_js: + - '0.12' + - 'iojs' + - '4.0' + - '6.0' diff --git a/node_modules/extract-zip/CONTRIBUTING.md b/node_modules/extract-zip/CONTRIBUTING.md new file mode 100644 index 0000000..eea6b39 --- /dev/null +++ b/node_modules/extract-zip/CONTRIBUTING.md @@ -0,0 +1 @@ +Before potentially wasting your time by making major, opinionated changes to this codebase please feel free to open a discussion repos in the Issues section of the repository. Outline your proposed idea and seek feedback from the maintainer first before implementing major features.
\ No newline at end of file diff --git a/node_modules/extract-zip/LICENSE b/node_modules/extract-zip/LICENSE new file mode 100644 index 0000000..2921069 --- /dev/null +++ b/node_modules/extract-zip/LICENSE @@ -0,0 +1,23 @@ +Copyright (c) 2014 Max Ogden and other contributors +All rights reserved. + +Redistribution and use in source and binary forms, with or without +modification, are permitted provided that the following conditions are met: + +* Redistributions of source code must retain the above copyright notice, this + list of conditions and the following disclaimer. + +* Redistributions in binary form must reproduce the above copyright notice, + this list of conditions and the following disclaimer in the documentation + and/or other materials provided with the distribution. + +THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" +AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE +IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE +DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE +FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL +DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR +SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER +CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, +OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. diff --git a/node_modules/extract-zip/cli.js b/node_modules/extract-zip/cli.js new file mode 100755 index 0000000..76c337d --- /dev/null +++ b/node_modules/extract-zip/cli.js @@ -0,0 +1,20 @@ +#!/usr/bin/env node + +var extract = require('./') + +var args = process.argv.slice(2) +var source = args[0] +var dest = args[1] || process.cwd() +if (!source) { + console.error('Usage: extract-zip foo.zip <targetDirectory>') + process.exit(1) +} + +extract(source, {dir: dest}, function (err, results) { + if (err) { + console.error('error!', err) + process.exit(1) + } else { + process.exit(0) + } +}) diff --git a/node_modules/extract-zip/index.js b/node_modules/extract-zip/index.js new file mode 100644 index 0000000..8c193e4 --- /dev/null +++ b/node_modules/extract-zip/index.js @@ -0,0 +1,205 @@ +var fs = require('fs') +var path = require('path') +var yauzl = require('yauzl') +var mkdirp = require('mkdirp') +var concat = require('concat-stream') +var debug = require('debug')('extract-zip') + +module.exports = function (zipPath, opts, cb) { + debug('creating target directory', opts.dir) + + if (path.isAbsolute(opts.dir) === false) { + return cb(new Error('Target directory is expected to be absolute')) + } + + mkdirp(opts.dir, function (err) { + if (err) return cb(err) + + fs.realpath(opts.dir, function (err, canonicalDir) { + if (err) return cb(err) + + opts.dir = canonicalDir + + openZip(opts) + }) + }) + + function openZip () { + debug('opening', zipPath, 'with opts', opts) + + yauzl.open(zipPath, {lazyEntries: true}, function (err, zipfile) { + if (err) return cb(err) + + var cancelled = false + + zipfile.readEntry() + + zipfile.on('close', function () { + if (!cancelled) { + debug('zip extraction complete') + cb() + } + }) + + zipfile.on('entry', function (entry) { + if (cancelled) { + debug('skipping entry', entry.fileName, {cancelled: cancelled}) + return + } + + debug('zipfile entry', entry.fileName) + + if (/^__MACOSX\//.test(entry.fileName)) { + // dir name starts with __MACOSX/ + zipfile.readEntry() + return + } + + var destDir = path.dirname(path.join(opts.dir, entry.fileName)) + + mkdirp(destDir, function (err) { + if (err) { + cancelled = true + zipfile.close() + return cb(err) + } + + fs.realpath(destDir, function (err, canonicalDestDir) { + if (err) { + cancelled = true + zipfile.close() + return cb(err) + } + + var relativeDestDir = path.relative(opts.dir, canonicalDestDir) + + if (relativeDestDir.split(path.sep).indexOf('..') !== -1) { + cancelled = true + zipfile.close() + return cb(new Error('Out of bound path "' + canonicalDestDir + '" found while processing file ' + entry.fileName)) + } + + extractEntry(entry, function (err) { + // if any extraction fails then abort everything + if (err) { + cancelled = true + zipfile.close() + return cb(err) + } + debug('finished processing', entry.fileName) + zipfile.readEntry() + }) + }) + }) + }) + + function extractEntry (entry, done) { + if (cancelled) { + debug('skipping entry extraction', entry.fileName, {cancelled: cancelled}) + return setImmediate(done) + } + + if (opts.onEntry) { + opts.onEntry(entry, zipfile) + } + + var dest = path.join(opts.dir, entry.fileName) + + // convert external file attr int into a fs stat mode int + var mode = (entry.externalFileAttributes >> 16) & 0xFFFF + // check if it's a symlink or dir (using stat mode constants) + var IFMT = 61440 + var IFDIR = 16384 + var IFLNK = 40960 + var symlink = (mode & IFMT) === IFLNK + var isDir = (mode & IFMT) === IFDIR + + // Failsafe, borrowed from jsZip + if (!isDir && entry.fileName.slice(-1) === '/') { + isDir = true + } + + // check for windows weird way of specifying a directory + // https://github.com/maxogden/extract-zip/issues/13#issuecomment-154494566 + var madeBy = entry.versionMadeBy >> 8 + if (!isDir) isDir = (madeBy === 0 && entry.externalFileAttributes === 16) + + // if no mode then default to default modes + if (mode === 0) { + if (isDir) { + if (opts.defaultDirMode) mode = parseInt(opts.defaultDirMode, 10) + if (!mode) mode = 493 // Default to 0755 + } else { + if (opts.defaultFileMode) mode = parseInt(opts.defaultFileMode, 10) + if (!mode) mode = 420 // Default to 0644 + } + } + + debug('extracting entry', { filename: entry.fileName, isDir: isDir, isSymlink: symlink }) + + // reverse umask first (~) + var umask = ~process.umask() + // & with processes umask to override invalid perms + var procMode = mode & umask + + // always ensure folders are created + var destDir = dest + if (!isDir) destDir = path.dirname(dest) + + debug('mkdirp', {dir: destDir}) + mkdirp(destDir, function (err) { + if (err) { + debug('mkdirp error', destDir, {error: err}) + cancelled = true + return done(err) + } + + if (isDir) return done() + + debug('opening read stream', dest) + zipfile.openReadStream(entry, function (err, readStream) { + if (err) { + debug('openReadStream error', err) + cancelled = true + return done(err) + } + + readStream.on('error', function (err) { + console.log('read err', err) + }) + + if (symlink) writeSymlink() + else writeStream() + + function writeStream () { + var writeStream = fs.createWriteStream(dest, {mode: procMode}) + readStream.pipe(writeStream) + + writeStream.on('finish', function () { + done() + }) + + writeStream.on('error', function (err) { + debug('write error', {error: err}) + cancelled = true + return done(err) + }) + } + + // AFAICT the content of the symlink file itself is the symlink target filename string + function writeSymlink () { + readStream.pipe(concat(function (data) { + var link = data.toString() + debug('creating symlink', link, dest) + fs.symlink(link, dest, function (err) { + if (err) cancelled = true + done(err) + }) + })) + } + }) + }) + } + }) + } +} diff --git a/node_modules/extract-zip/package.json b/node_modules/extract-zip/package.json new file mode 100644 index 0000000..8d4e4f2 --- /dev/null +++ b/node_modules/extract-zip/package.json @@ -0,0 +1,69 @@ +{ + "_from": "extract-zip@^1.0.3", + "_id": "[email protected]", + "_inBundle": false, + "_integrity": "sha1-EpDt6NINCHK0Kf0/NRyhKOxe+Fw=", + "_location": "/extract-zip", + "_phantomChildren": {}, + "_requested": { + "type": "range", + "registry": true, + "raw": "extract-zip@^1.0.3", + "name": "extract-zip", + "escapedName": "extract-zip", + "rawSpec": "^1.0.3", + "saveSpec": null, + "fetchSpec": "^1.0.3" + }, + "_requiredBy": [ + "/electron" + ], + "_resolved": "https://registry.npmjs.org/extract-zip/-/extract-zip-1.6.6.tgz", + "_shasum": "1290ede8d20d0872b429fd3f351ca128ec5ef85c", + "_spec": "extract-zip@^1.0.3", + "_where": "/Users/armanshah/Desktop/node-projects/shopping-list/node_modules/electron", + "author": { + "name": "max ogden" + }, + "bin": { + "extract-zip": "cli.js" + }, + "bugs": { + "url": "https://github.com/maxogden/extract-zip/issues" + }, + "bundleDependencies": false, + "dependencies": { + "concat-stream": "1.6.0", + "debug": "2.6.9", + "mkdirp": "0.5.0", + "yauzl": "2.4.1" + }, + "deprecated": false, + "description": "unzip a zip file into a directory using 100% javascript", + "devDependencies": { + "rimraf": "^2.2.8", + "standard": "^5.2.2", + "tape": "^4.2.0", + "temp": "^0.8.3" + }, + "directories": { + "test": "test" + }, + "homepage": "https://github.com/maxogden/extract-zip#readme", + "keywords": [ + "unzip", + "zip", + "extract" + ], + "license": "BSD-2-Clause", + "main": "index.js", + "name": "extract-zip", + "repository": { + "type": "git", + "url": "git+https://github.com/maxogden/extract-zip.git" + }, + "scripts": { + "test": "standard && node test/test.js" + }, + "version": "1.6.6" +} diff --git a/node_modules/extract-zip/readme.md b/node_modules/extract-zip/readme.md new file mode 100644 index 0000000..af17885 --- /dev/null +++ b/node_modules/extract-zip/readme.md @@ -0,0 +1,49 @@ +# 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`](http://npmjs.org/yauzl) ZIP parser. + +[](https://nodei.co/npm/extract-zip/) +[](https://github.com/feross/standard) +[](https://travis-ci.org/maxogden/extract-zip) + +## Installation + +Get the library: + +``` +npm install extract-zip --save +``` + +Install the command line program: + +``` +npm install extract-zip -g +``` + +## JS API + +```js +var extract = require('extract-zip') +extract(source, {dir: target}, function (err) { + // extraction is complete. make sure to handle the err +}) +``` + +### Options + +- `dir` - defaults to `process.cwd()` +- `defaultDirMode` - integer - Directory Mode (permissions) will default to `493` (octal `0755` in integer) +- `defaultFileMode` - integer - File Mode (permissions) will default to `420` (octal `0644` in integer) +- `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()`. |