FRE-709: Document duplicate recovery wake - FRE-635 already recovered via FRE-708
This commit is contained in:
9
node_modules/extract-zip/.travis.yml
generated
vendored
Normal file
9
node_modules/extract-zip/.travis.yml
generated
vendored
Normal file
@@ -0,0 +1,9 @@
|
||||
sudo: false
|
||||
language: node_js
|
||||
node_js:
|
||||
- '0.12'
|
||||
- 'iojs'
|
||||
- '4'
|
||||
- '6'
|
||||
- '8'
|
||||
- '10'
|
||||
1
node_modules/extract-zip/CONTRIBUTING.md
generated
vendored
Normal file
1
node_modules/extract-zip/CONTRIBUTING.md
generated
vendored
Normal file
@@ -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.
|
||||
23
node_modules/extract-zip/LICENSE
generated
vendored
Normal file
23
node_modules/extract-zip/LICENSE
generated
vendored
Normal file
@@ -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.
|
||||
20
node_modules/extract-zip/cli.js
generated
vendored
Executable file
20
node_modules/extract-zip/cli.js
generated
vendored
Executable file
@@ -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)
|
||||
}
|
||||
})
|
||||
211
node_modules/extract-zip/index.js
generated
vendored
Normal file
211
node_modules/extract-zip/index.js
generated
vendored
Normal file
@@ -0,0 +1,211 @@
|
||||
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.on('error', function (err) {
|
||||
if (err) {
|
||||
cancelled = true
|
||||
return cb(err)
|
||||
}
|
||||
})
|
||||
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)
|
||||
})
|
||||
}))
|
||||
}
|
||||
})
|
||||
})
|
||||
}
|
||||
})
|
||||
}
|
||||
}
|
||||
21
node_modules/extract-zip/node_modules/mkdirp/LICENSE
generated
vendored
Normal file
21
node_modules/extract-zip/node_modules/mkdirp/LICENSE
generated
vendored
Normal file
@@ -0,0 +1,21 @@
|
||||
Copyright 2010 James Halliday (mail@substack.net)
|
||||
|
||||
This project is free software released under the MIT/X11 license:
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
of this software and associated documentation files (the "Software"), to deal
|
||||
in the Software without restriction, including without limitation the rights
|
||||
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
copies of the Software, and to permit persons to whom the Software is
|
||||
furnished to do so, subject to the following conditions:
|
||||
|
||||
The above copyright notice and this permission notice shall be included in
|
||||
all copies or substantial portions of the Software.
|
||||
|
||||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
||||
THE SOFTWARE.
|
||||
33
node_modules/extract-zip/node_modules/mkdirp/bin/cmd.js
generated
vendored
Executable file
33
node_modules/extract-zip/node_modules/mkdirp/bin/cmd.js
generated
vendored
Executable file
@@ -0,0 +1,33 @@
|
||||
#!/usr/bin/env node
|
||||
|
||||
var mkdirp = require('../');
|
||||
var minimist = require('minimist');
|
||||
var fs = require('fs');
|
||||
|
||||
var argv = minimist(process.argv.slice(2), {
|
||||
alias: { m: 'mode', h: 'help' },
|
||||
string: [ 'mode' ]
|
||||
});
|
||||
if (argv.help) {
|
||||
fs.createReadStream(__dirname + '/usage.txt').pipe(process.stdout);
|
||||
return;
|
||||
}
|
||||
|
||||
var paths = argv._.slice();
|
||||
var mode = argv.mode ? parseInt(argv.mode, 8) : undefined;
|
||||
|
||||
(function next () {
|
||||
if (paths.length === 0) return;
|
||||
var p = paths.shift();
|
||||
|
||||
if (mode === undefined) mkdirp(p, cb)
|
||||
else mkdirp(p, mode, cb)
|
||||
|
||||
function cb (err) {
|
||||
if (err) {
|
||||
console.error(err.message);
|
||||
process.exit(1);
|
||||
}
|
||||
else next();
|
||||
}
|
||||
})();
|
||||
12
node_modules/extract-zip/node_modules/mkdirp/bin/usage.txt
generated
vendored
Normal file
12
node_modules/extract-zip/node_modules/mkdirp/bin/usage.txt
generated
vendored
Normal file
@@ -0,0 +1,12 @@
|
||||
usage: mkdirp [DIR1,DIR2..] {OPTIONS}
|
||||
|
||||
Create each supplied directory including any necessary parent directories that
|
||||
don't yet exist.
|
||||
|
||||
If the directory already exists, do nothing.
|
||||
|
||||
OPTIONS are:
|
||||
|
||||
-m, --mode If a directory needs to be created, set the mode as an octal
|
||||
permission string.
|
||||
|
||||
102
node_modules/extract-zip/node_modules/mkdirp/index.js
generated
vendored
Normal file
102
node_modules/extract-zip/node_modules/mkdirp/index.js
generated
vendored
Normal file
@@ -0,0 +1,102 @@
|
||||
var path = require('path');
|
||||
var fs = require('fs');
|
||||
var _0777 = parseInt('0777', 8);
|
||||
|
||||
module.exports = mkdirP.mkdirp = mkdirP.mkdirP = mkdirP;
|
||||
|
||||
function mkdirP (p, opts, f, made) {
|
||||
if (typeof opts === 'function') {
|
||||
f = opts;
|
||||
opts = {};
|
||||
}
|
||||
else if (!opts || typeof opts !== 'object') {
|
||||
opts = { mode: opts };
|
||||
}
|
||||
|
||||
var mode = opts.mode;
|
||||
var xfs = opts.fs || fs;
|
||||
|
||||
if (mode === undefined) {
|
||||
mode = _0777
|
||||
}
|
||||
if (!made) made = null;
|
||||
|
||||
var cb = f || /* istanbul ignore next */ function () {};
|
||||
p = path.resolve(p);
|
||||
|
||||
xfs.mkdir(p, mode, function (er) {
|
||||
if (!er) {
|
||||
made = made || p;
|
||||
return cb(null, made);
|
||||
}
|
||||
switch (er.code) {
|
||||
case 'ENOENT':
|
||||
/* istanbul ignore if */
|
||||
if (path.dirname(p) === p) return cb(er);
|
||||
mkdirP(path.dirname(p), opts, function (er, made) {
|
||||
/* istanbul ignore if */
|
||||
if (er) cb(er, made);
|
||||
else mkdirP(p, opts, cb, made);
|
||||
});
|
||||
break;
|
||||
|
||||
// In the case of any other error, just see if there's a dir
|
||||
// there already. If so, then hooray! If not, then something
|
||||
// is borked.
|
||||
default:
|
||||
xfs.stat(p, function (er2, stat) {
|
||||
// if the stat fails, then that's super weird.
|
||||
// let the original error be the failure reason.
|
||||
if (er2 || !stat.isDirectory()) cb(er, made)
|
||||
else cb(null, made);
|
||||
});
|
||||
break;
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
mkdirP.sync = function sync (p, opts, made) {
|
||||
if (!opts || typeof opts !== 'object') {
|
||||
opts = { mode: opts };
|
||||
}
|
||||
|
||||
var mode = opts.mode;
|
||||
var xfs = opts.fs || fs;
|
||||
|
||||
if (mode === undefined) {
|
||||
mode = _0777
|
||||
}
|
||||
if (!made) made = null;
|
||||
|
||||
p = path.resolve(p);
|
||||
|
||||
try {
|
||||
xfs.mkdirSync(p, mode);
|
||||
made = made || p;
|
||||
}
|
||||
catch (err0) {
|
||||
switch (err0.code) {
|
||||
case 'ENOENT' :
|
||||
made = sync(path.dirname(p), opts, made);
|
||||
sync(p, opts, made);
|
||||
break;
|
||||
|
||||
// In the case of any other error, just see if there's a dir
|
||||
// there already. If so, then hooray! If not, then something
|
||||
// is borked.
|
||||
default:
|
||||
var stat;
|
||||
try {
|
||||
stat = xfs.statSync(p);
|
||||
}
|
||||
catch (err1) /* istanbul ignore next */ {
|
||||
throw err0;
|
||||
}
|
||||
/* istanbul ignore if */
|
||||
if (!stat.isDirectory()) throw err0;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
return made;
|
||||
};
|
||||
33
node_modules/extract-zip/node_modules/mkdirp/package.json
generated
vendored
Normal file
33
node_modules/extract-zip/node_modules/mkdirp/package.json
generated
vendored
Normal file
@@ -0,0 +1,33 @@
|
||||
{
|
||||
"name": "mkdirp",
|
||||
"description": "Recursively mkdir, like `mkdir -p`",
|
||||
"version": "0.5.6",
|
||||
"publishConfig": {
|
||||
"tag": "legacy"
|
||||
},
|
||||
"author": "James Halliday <mail@substack.net> (http://substack.net)",
|
||||
"main": "index.js",
|
||||
"keywords": [
|
||||
"mkdir",
|
||||
"directory"
|
||||
],
|
||||
"repository": {
|
||||
"type": "git",
|
||||
"url": "https://github.com/substack/node-mkdirp.git"
|
||||
},
|
||||
"scripts": {
|
||||
"test": "tap test/*.js"
|
||||
},
|
||||
"dependencies": {
|
||||
"minimist": "^1.2.6"
|
||||
},
|
||||
"devDependencies": {
|
||||
"tap": "^16.0.1"
|
||||
},
|
||||
"bin": "bin/cmd.js",
|
||||
"license": "MIT",
|
||||
"files": [
|
||||
"bin",
|
||||
"index.js"
|
||||
]
|
||||
}
|
||||
100
node_modules/extract-zip/node_modules/mkdirp/readme.markdown
generated
vendored
Normal file
100
node_modules/extract-zip/node_modules/mkdirp/readme.markdown
generated
vendored
Normal file
@@ -0,0 +1,100 @@
|
||||
# mkdirp
|
||||
|
||||
Like `mkdir -p`, but in node.js!
|
||||
|
||||
[](http://travis-ci.org/substack/node-mkdirp)
|
||||
|
||||
# example
|
||||
|
||||
## pow.js
|
||||
|
||||
```js
|
||||
var mkdirp = require('mkdirp');
|
||||
|
||||
mkdirp('/tmp/foo/bar/baz', function (err) {
|
||||
if (err) console.error(err)
|
||||
else console.log('pow!')
|
||||
});
|
||||
```
|
||||
|
||||
Output
|
||||
|
||||
```
|
||||
pow!
|
||||
```
|
||||
|
||||
And now /tmp/foo/bar/baz exists, huzzah!
|
||||
|
||||
# methods
|
||||
|
||||
```js
|
||||
var mkdirp = require('mkdirp');
|
||||
```
|
||||
|
||||
## mkdirp(dir, opts, cb)
|
||||
|
||||
Create a new directory and any necessary subdirectories at `dir` with octal
|
||||
permission string `opts.mode`. If `opts` is a non-object, it will be treated as
|
||||
the `opts.mode`.
|
||||
|
||||
If `opts.mode` isn't specified, it defaults to `0777`.
|
||||
|
||||
`cb(err, made)` fires with the error or the first directory `made`
|
||||
that had to be created, if any.
|
||||
|
||||
You can optionally pass in an alternate `fs` implementation by passing in
|
||||
`opts.fs`. Your implementation should have `opts.fs.mkdir(path, mode, cb)` and
|
||||
`opts.fs.stat(path, cb)`.
|
||||
|
||||
## mkdirp.sync(dir, opts)
|
||||
|
||||
Synchronously create a new directory and any necessary subdirectories at `dir`
|
||||
with octal permission string `opts.mode`. If `opts` is a non-object, it will be
|
||||
treated as the `opts.mode`.
|
||||
|
||||
If `opts.mode` isn't specified, it defaults to `0777`.
|
||||
|
||||
Returns the first directory that had to be created, if any.
|
||||
|
||||
You can optionally pass in an alternate `fs` implementation by passing in
|
||||
`opts.fs`. Your implementation should have `opts.fs.mkdirSync(path, mode)` and
|
||||
`opts.fs.statSync(path)`.
|
||||
|
||||
# usage
|
||||
|
||||
This package also ships with a `mkdirp` command.
|
||||
|
||||
```
|
||||
usage: mkdirp [DIR1,DIR2..] {OPTIONS}
|
||||
|
||||
Create each supplied directory including any necessary parent directories that
|
||||
don't yet exist.
|
||||
|
||||
If the directory already exists, do nothing.
|
||||
|
||||
OPTIONS are:
|
||||
|
||||
-m, --mode If a directory needs to be created, set the mode as an octal
|
||||
permission string.
|
||||
|
||||
```
|
||||
|
||||
# install
|
||||
|
||||
With [npm](http://npmjs.org) do:
|
||||
|
||||
```
|
||||
npm install mkdirp
|
||||
```
|
||||
|
||||
to get the library, or
|
||||
|
||||
```
|
||||
npm install -g mkdirp
|
||||
```
|
||||
|
||||
to get the command.
|
||||
|
||||
# license
|
||||
|
||||
MIT
|
||||
152
node_modules/extract-zip/node_modules/ms/index.js
generated
vendored
Normal file
152
node_modules/extract-zip/node_modules/ms/index.js
generated
vendored
Normal file
@@ -0,0 +1,152 @@
|
||||
/**
|
||||
* Helpers.
|
||||
*/
|
||||
|
||||
var s = 1000;
|
||||
var m = s * 60;
|
||||
var h = m * 60;
|
||||
var d = h * 24;
|
||||
var y = d * 365.25;
|
||||
|
||||
/**
|
||||
* Parse or format the given `val`.
|
||||
*
|
||||
* Options:
|
||||
*
|
||||
* - `long` verbose formatting [false]
|
||||
*
|
||||
* @param {String|Number} val
|
||||
* @param {Object} [options]
|
||||
* @throws {Error} throw an error if val is not a non-empty string or a number
|
||||
* @return {String|Number}
|
||||
* @api public
|
||||
*/
|
||||
|
||||
module.exports = function(val, options) {
|
||||
options = options || {};
|
||||
var type = typeof val;
|
||||
if (type === 'string' && val.length > 0) {
|
||||
return parse(val);
|
||||
} else if (type === 'number' && isNaN(val) === false) {
|
||||
return options.long ? fmtLong(val) : fmtShort(val);
|
||||
}
|
||||
throw new Error(
|
||||
'val is not a non-empty string or a valid number. val=' +
|
||||
JSON.stringify(val)
|
||||
);
|
||||
};
|
||||
|
||||
/**
|
||||
* Parse the given `str` and return milliseconds.
|
||||
*
|
||||
* @param {String} str
|
||||
* @return {Number}
|
||||
* @api private
|
||||
*/
|
||||
|
||||
function parse(str) {
|
||||
str = String(str);
|
||||
if (str.length > 100) {
|
||||
return;
|
||||
}
|
||||
var match = /^((?:\d+)?\.?\d+) *(milliseconds?|msecs?|ms|seconds?|secs?|s|minutes?|mins?|m|hours?|hrs?|h|days?|d|years?|yrs?|y)?$/i.exec(
|
||||
str
|
||||
);
|
||||
if (!match) {
|
||||
return;
|
||||
}
|
||||
var n = parseFloat(match[1]);
|
||||
var type = (match[2] || 'ms').toLowerCase();
|
||||
switch (type) {
|
||||
case 'years':
|
||||
case 'year':
|
||||
case 'yrs':
|
||||
case 'yr':
|
||||
case 'y':
|
||||
return n * y;
|
||||
case 'days':
|
||||
case 'day':
|
||||
case 'd':
|
||||
return n * d;
|
||||
case 'hours':
|
||||
case 'hour':
|
||||
case 'hrs':
|
||||
case 'hr':
|
||||
case 'h':
|
||||
return n * h;
|
||||
case 'minutes':
|
||||
case 'minute':
|
||||
case 'mins':
|
||||
case 'min':
|
||||
case 'm':
|
||||
return n * m;
|
||||
case 'seconds':
|
||||
case 'second':
|
||||
case 'secs':
|
||||
case 'sec':
|
||||
case 's':
|
||||
return n * s;
|
||||
case 'milliseconds':
|
||||
case 'millisecond':
|
||||
case 'msecs':
|
||||
case 'msec':
|
||||
case 'ms':
|
||||
return n;
|
||||
default:
|
||||
return undefined;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Short format for `ms`.
|
||||
*
|
||||
* @param {Number} ms
|
||||
* @return {String}
|
||||
* @api private
|
||||
*/
|
||||
|
||||
function fmtShort(ms) {
|
||||
if (ms >= d) {
|
||||
return Math.round(ms / d) + 'd';
|
||||
}
|
||||
if (ms >= h) {
|
||||
return Math.round(ms / h) + 'h';
|
||||
}
|
||||
if (ms >= m) {
|
||||
return Math.round(ms / m) + 'm';
|
||||
}
|
||||
if (ms >= s) {
|
||||
return Math.round(ms / s) + 's';
|
||||
}
|
||||
return ms + 'ms';
|
||||
}
|
||||
|
||||
/**
|
||||
* Long format for `ms`.
|
||||
*
|
||||
* @param {Number} ms
|
||||
* @return {String}
|
||||
* @api private
|
||||
*/
|
||||
|
||||
function fmtLong(ms) {
|
||||
return plural(ms, d, 'day') ||
|
||||
plural(ms, h, 'hour') ||
|
||||
plural(ms, m, 'minute') ||
|
||||
plural(ms, s, 'second') ||
|
||||
ms + ' ms';
|
||||
}
|
||||
|
||||
/**
|
||||
* Pluralization helper.
|
||||
*/
|
||||
|
||||
function plural(ms, n, name) {
|
||||
if (ms < n) {
|
||||
return;
|
||||
}
|
||||
if (ms < n * 1.5) {
|
||||
return Math.floor(ms / n) + ' ' + name;
|
||||
}
|
||||
return Math.ceil(ms / n) + ' ' + name + 's';
|
||||
}
|
||||
21
node_modules/extract-zip/node_modules/ms/license.md
generated
vendored
Normal file
21
node_modules/extract-zip/node_modules/ms/license.md
generated
vendored
Normal file
@@ -0,0 +1,21 @@
|
||||
The MIT License (MIT)
|
||||
|
||||
Copyright (c) 2016 Zeit, Inc.
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
of this software and associated documentation files (the "Software"), to deal
|
||||
in the Software without restriction, including without limitation the rights
|
||||
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
copies of the Software, and to permit persons to whom the Software is
|
||||
furnished to do so, subject to the following conditions:
|
||||
|
||||
The above copyright notice and this permission notice shall be included in all
|
||||
copies or substantial portions of the Software.
|
||||
|
||||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||
SOFTWARE.
|
||||
37
node_modules/extract-zip/node_modules/ms/package.json
generated
vendored
Normal file
37
node_modules/extract-zip/node_modules/ms/package.json
generated
vendored
Normal file
@@ -0,0 +1,37 @@
|
||||
{
|
||||
"name": "ms",
|
||||
"version": "2.0.0",
|
||||
"description": "Tiny milisecond conversion utility",
|
||||
"repository": "zeit/ms",
|
||||
"main": "./index",
|
||||
"files": [
|
||||
"index.js"
|
||||
],
|
||||
"scripts": {
|
||||
"precommit": "lint-staged",
|
||||
"lint": "eslint lib/* bin/*",
|
||||
"test": "mocha tests.js"
|
||||
},
|
||||
"eslintConfig": {
|
||||
"extends": "eslint:recommended",
|
||||
"env": {
|
||||
"node": true,
|
||||
"es6": true
|
||||
}
|
||||
},
|
||||
"lint-staged": {
|
||||
"*.js": [
|
||||
"npm run lint",
|
||||
"prettier --single-quote --write",
|
||||
"git add"
|
||||
]
|
||||
},
|
||||
"license": "MIT",
|
||||
"devDependencies": {
|
||||
"eslint": "3.19.0",
|
||||
"expect.js": "0.3.1",
|
||||
"husky": "0.13.3",
|
||||
"lint-staged": "3.4.1",
|
||||
"mocha": "3.4.1"
|
||||
}
|
||||
}
|
||||
51
node_modules/extract-zip/node_modules/ms/readme.md
generated
vendored
Normal file
51
node_modules/extract-zip/node_modules/ms/readme.md
generated
vendored
Normal file
@@ -0,0 +1,51 @@
|
||||
# ms
|
||||
|
||||
[](https://travis-ci.org/zeit/ms)
|
||||
[](https://zeit.chat/)
|
||||
|
||||
Use this package to easily convert various time formats to milliseconds.
|
||||
|
||||
## Examples
|
||||
|
||||
```js
|
||||
ms('2 days') // 172800000
|
||||
ms('1d') // 86400000
|
||||
ms('10h') // 36000000
|
||||
ms('2.5 hrs') // 9000000
|
||||
ms('2h') // 7200000
|
||||
ms('1m') // 60000
|
||||
ms('5s') // 5000
|
||||
ms('1y') // 31557600000
|
||||
ms('100') // 100
|
||||
```
|
||||
|
||||
### Convert from milliseconds
|
||||
|
||||
```js
|
||||
ms(60000) // "1m"
|
||||
ms(2 * 60000) // "2m"
|
||||
ms(ms('10 hours')) // "10h"
|
||||
```
|
||||
|
||||
### Time format written-out
|
||||
|
||||
```js
|
||||
ms(60000, { long: true }) // "1 minute"
|
||||
ms(2 * 60000, { long: true }) // "2 minutes"
|
||||
ms(ms('10 hours'), { long: true }) // "10 hours"
|
||||
```
|
||||
|
||||
## Features
|
||||
|
||||
- Works both in [node](https://nodejs.org) and in the browser.
|
||||
- If a number is supplied to `ms`, a string with a unit is returned.
|
||||
- If a string that contains the number is supplied, it returns it as a number (e.g.: it returns `100` for `'100'`).
|
||||
- If you pass a string with a number and a valid unit, the number of equivalent ms is returned.
|
||||
|
||||
## Caught a bug?
|
||||
|
||||
1. [Fork](https://help.github.com/articles/fork-a-repo/) this repository to your own GitHub account and then [clone](https://help.github.com/articles/cloning-a-repository/) it to your local device
|
||||
2. Link the package to the global module directory: `npm link`
|
||||
3. Within the module you want to test your local development instance of ms, just link it to the dependencies: `npm link ms`. Instead of the default one from npm, node will now use your clone of ms!
|
||||
|
||||
As always, you can run the tests using: `npm test`
|
||||
35
node_modules/extract-zip/package.json
generated
vendored
Normal file
35
node_modules/extract-zip/package.json
generated
vendored
Normal file
@@ -0,0 +1,35 @@
|
||||
{
|
||||
"name": "extract-zip",
|
||||
"version": "1.7.0",
|
||||
"description": "unzip a zip file into a directory using 100% javascript",
|
||||
"main": "index.js",
|
||||
"bin": {
|
||||
"extract-zip": "cli.js"
|
||||
},
|
||||
"scripts": {
|
||||
"test": "standard && node test/test.js"
|
||||
},
|
||||
"author": "max ogden",
|
||||
"license": "BSD-2-Clause",
|
||||
"repository": "maxogden/extract-zip",
|
||||
"keywords": [
|
||||
"unzip",
|
||||
"zip",
|
||||
"extract"
|
||||
],
|
||||
"dependencies": {
|
||||
"concat-stream": "^1.6.2",
|
||||
"debug": "^2.6.9",
|
||||
"mkdirp": "^0.5.4",
|
||||
"yauzl": "^2.10.0"
|
||||
},
|
||||
"devDependencies": {
|
||||
"rimraf": "^2.2.8",
|
||||
"standard": "^5.2.2",
|
||||
"tape": "^4.2.0",
|
||||
"temp": "^0.8.3"
|
||||
},
|
||||
"directories": {
|
||||
"test": "test"
|
||||
}
|
||||
}
|
||||
49
node_modules/extract-zip/readme.md
generated
vendored
Normal file
49
node_modules/extract-zip/readme.md
generated
vendored
Normal file
@@ -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()`.
|
||||
Reference in New Issue
Block a user