Add some dependencies for uploading artifacts
This commit is contained in:
parent
1d05ad7576
commit
0cbd4b56d3
111 changed files with 9299 additions and 3597 deletions
21
node_modules/tmp/LICENSE
generated
vendored
Normal file
21
node_modules/tmp/LICENSE
generated
vendored
Normal file
|
|
@ -0,0 +1,21 @@
|
|||
The MIT License (MIT)
|
||||
|
||||
Copyright (c) 2014 KARASZI István
|
||||
|
||||
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.
|
||||
358
node_modules/tmp/README.md
generated
vendored
Normal file
358
node_modules/tmp/README.md
generated
vendored
Normal file
|
|
@ -0,0 +1,358 @@
|
|||
# Tmp
|
||||
|
||||
A simple temporary file and directory creator for [node.js.][1]
|
||||
|
||||
[](https://travis-ci.org/raszi/node-tmp)
|
||||
[](https://david-dm.org/raszi/node-tmp)
|
||||
[](https://badge.fury.io/js/tmp)
|
||||
[](https://raszi.github.io/node-tmp/)
|
||||
[](https://snyk.io/test/npm/tmp)
|
||||
|
||||
## About
|
||||
|
||||
This is a [widely used library][2] to create temporary files and directories
|
||||
in a [node.js][1] environment.
|
||||
|
||||
Tmp offers both an asynchronous and a synchronous API. For all API calls, all
|
||||
the parameters are optional. There also exists a promisified version of the
|
||||
API, see [tmp-promise][5].
|
||||
|
||||
Tmp uses crypto for determining random file names, or, when using templates,
|
||||
a six letter random identifier. And just in case that you do not have that much
|
||||
entropy left on your system, Tmp will fall back to pseudo random numbers.
|
||||
|
||||
You can set whether you want to remove the temporary file on process exit or
|
||||
not.
|
||||
|
||||
If you do not want to store your temporary directories and files in the
|
||||
standard OS temporary directory, then you are free to override that as well.
|
||||
|
||||
## An Important Note on Compatibility
|
||||
|
||||
### Version 0.1.0
|
||||
|
||||
Since version 0.1.0, all support for node versions < 0.10.0 has been dropped.
|
||||
|
||||
Most importantly, any support for earlier versions of node-tmp was also dropped.
|
||||
|
||||
If you still require node versions < 0.10.0, then you must limit your node-tmp
|
||||
dependency to versions below 0.1.0.
|
||||
|
||||
### Version 0.0.33
|
||||
|
||||
Since version 0.0.33, all support for node versions < 0.8 has been dropped.
|
||||
|
||||
If you still require node version 0.8, then you must limit your node-tmp
|
||||
dependency to version 0.0.33.
|
||||
|
||||
For node versions < 0.8 you must limit your node-tmp dependency to
|
||||
versions < 0.0.33.
|
||||
|
||||
### Node Versions < 8.12.0
|
||||
|
||||
The SIGINT handler will not work correctly with versions of NodeJS < 8.12.0.
|
||||
|
||||
### Windows
|
||||
|
||||
Signal handlers for SIGINT will not work. Pressing CTRL-C will leave behind
|
||||
temporary files and directories.
|
||||
|
||||
## How to install
|
||||
|
||||
```bash
|
||||
npm install tmp
|
||||
```
|
||||
|
||||
## Usage
|
||||
|
||||
Please also check [API docs][4].
|
||||
|
||||
### Asynchronous file creation
|
||||
|
||||
Simple temporary file creation, the file will be closed and unlinked on process exit.
|
||||
|
||||
```javascript
|
||||
var tmp = require('tmp');
|
||||
|
||||
tmp.file(function _tempFileCreated(err, path, fd, cleanupCallback) {
|
||||
if (err) throw err;
|
||||
|
||||
console.log('File: ', path);
|
||||
console.log('Filedescriptor: ', fd);
|
||||
|
||||
// If we don't need the file anymore we could manually call the cleanupCallback
|
||||
// But that is not necessary if we didn't pass the keep option because the library
|
||||
// will clean after itself.
|
||||
cleanupCallback();
|
||||
});
|
||||
```
|
||||
|
||||
### Synchronous file creation
|
||||
|
||||
A synchronous version of the above.
|
||||
|
||||
```javascript
|
||||
var tmp = require('tmp');
|
||||
|
||||
var tmpobj = tmp.fileSync();
|
||||
console.log('File: ', tmpobj.name);
|
||||
console.log('Filedescriptor: ', tmpobj.fd);
|
||||
|
||||
// If we don't need the file anymore we could manually call the removeCallback
|
||||
// But that is not necessary if we didn't pass the keep option because the library
|
||||
// will clean after itself.
|
||||
tmpobj.removeCallback();
|
||||
```
|
||||
|
||||
Note that this might throw an exception if either the maximum limit of retries
|
||||
for creating a temporary name fails, or, in case that you do not have the permission
|
||||
to write to the directory where the temporary file should be created in.
|
||||
|
||||
### Asynchronous directory creation
|
||||
|
||||
Simple temporary directory creation, it will be removed on process exit.
|
||||
|
||||
If the directory still contains items on process exit, then it won't be removed.
|
||||
|
||||
```javascript
|
||||
var tmp = require('tmp');
|
||||
|
||||
tmp.dir(function _tempDirCreated(err, path, cleanupCallback) {
|
||||
if (err) throw err;
|
||||
|
||||
console.log('Dir: ', path);
|
||||
|
||||
// Manual cleanup
|
||||
cleanupCallback();
|
||||
});
|
||||
```
|
||||
|
||||
If you want to cleanup the directory even when there are entries in it, then
|
||||
you can pass the `unsafeCleanup` option when creating it.
|
||||
|
||||
### Synchronous directory creation
|
||||
|
||||
A synchronous version of the above.
|
||||
|
||||
```javascript
|
||||
var tmp = require('tmp');
|
||||
|
||||
var tmpobj = tmp.dirSync();
|
||||
console.log('Dir: ', tmpobj.name);
|
||||
// Manual cleanup
|
||||
tmpobj.removeCallback();
|
||||
```
|
||||
|
||||
Note that this might throw an exception if either the maximum limit of retries
|
||||
for creating a temporary name fails, or, in case that you do not have the permission
|
||||
to write to the directory where the temporary directory should be created in.
|
||||
|
||||
### Asynchronous filename generation
|
||||
|
||||
It is possible with this library to generate a unique filename in the specified
|
||||
directory.
|
||||
|
||||
```javascript
|
||||
var tmp = require('tmp');
|
||||
|
||||
tmp.tmpName(function _tempNameGenerated(err, path) {
|
||||
if (err) throw err;
|
||||
|
||||
console.log('Created temporary filename: ', path);
|
||||
});
|
||||
```
|
||||
|
||||
### Synchronous filename generation
|
||||
|
||||
A synchronous version of the above.
|
||||
|
||||
```javascript
|
||||
var tmp = require('tmp');
|
||||
|
||||
var name = tmp.tmpNameSync();
|
||||
console.log('Created temporary filename: ', name);
|
||||
```
|
||||
|
||||
## Advanced usage
|
||||
|
||||
### Asynchronous file creation
|
||||
|
||||
Creates a file with mode `0644`, prefix will be `prefix-` and postfix will be `.txt`.
|
||||
|
||||
```javascript
|
||||
var tmp = require('tmp');
|
||||
|
||||
tmp.file({ mode: 0644, prefix: 'prefix-', postfix: '.txt' }, function _tempFileCreated(err, path, fd) {
|
||||
if (err) throw err;
|
||||
|
||||
console.log('File: ', path);
|
||||
console.log('Filedescriptor: ', fd);
|
||||
});
|
||||
```
|
||||
|
||||
### Synchronous file creation
|
||||
|
||||
A synchronous version of the above.
|
||||
|
||||
```javascript
|
||||
var tmp = require('tmp');
|
||||
|
||||
var tmpobj = tmp.fileSync({ mode: 0644, prefix: 'prefix-', postfix: '.txt' });
|
||||
console.log('File: ', tmpobj.name);
|
||||
console.log('Filedescriptor: ', tmpobj.fd);
|
||||
```
|
||||
|
||||
### Controlling the Descriptor
|
||||
|
||||
As a side effect of creating a unique file `tmp` gets a file descriptor that is
|
||||
returned to the user as the `fd` parameter. The descriptor may be used by the
|
||||
application and is closed when the `removeCallback` is invoked.
|
||||
|
||||
In some use cases the application does not need the descriptor, needs to close it
|
||||
without removing the file, or needs to remove the file without closing the
|
||||
descriptor. Two options control how the descriptor is managed:
|
||||
|
||||
* `discardDescriptor` - if `true` causes `tmp` to close the descriptor after the file
|
||||
is created. In this case the `fd` parameter is undefined.
|
||||
* `detachDescriptor` - if `true` causes `tmp` to return the descriptor in the `fd`
|
||||
parameter, but it is the application's responsibility to close it when it is no
|
||||
longer needed.
|
||||
|
||||
```javascript
|
||||
var tmp = require('tmp');
|
||||
|
||||
tmp.file({ discardDescriptor: true }, function _tempFileCreated(err, path, fd, cleanupCallback) {
|
||||
if (err) throw err;
|
||||
// fd will be undefined, allowing application to use fs.createReadStream(path)
|
||||
// without holding an unused descriptor open.
|
||||
});
|
||||
```
|
||||
|
||||
```javascript
|
||||
var tmp = require('tmp');
|
||||
|
||||
tmp.file({ detachDescriptor: true }, function _tempFileCreated(err, path, fd, cleanupCallback) {
|
||||
if (err) throw err;
|
||||
|
||||
cleanupCallback();
|
||||
// Application can store data through fd here; the space used will automatically
|
||||
// be reclaimed by the operating system when the descriptor is closed or program
|
||||
// terminates.
|
||||
});
|
||||
```
|
||||
|
||||
### Asynchronous directory creation
|
||||
|
||||
Creates a directory with mode `0755`, prefix will be `myTmpDir_`.
|
||||
|
||||
```javascript
|
||||
var tmp = require('tmp');
|
||||
|
||||
tmp.dir({ mode: 0750, prefix: 'myTmpDir_' }, function _tempDirCreated(err, path) {
|
||||
if (err) throw err;
|
||||
|
||||
console.log('Dir: ', path);
|
||||
});
|
||||
```
|
||||
|
||||
### Synchronous directory creation
|
||||
|
||||
Again, a synchronous version of the above.
|
||||
|
||||
```javascript
|
||||
var tmp = require('tmp');
|
||||
|
||||
var tmpobj = tmp.dirSync({ mode: 0750, prefix: 'myTmpDir_' });
|
||||
console.log('Dir: ', tmpobj.name);
|
||||
```
|
||||
|
||||
### mkstemp like, asynchronously
|
||||
|
||||
Creates a new temporary directory with mode `0700` and filename like `/tmp/tmp-nk2J1u`.
|
||||
|
||||
IMPORTANT NOTE: template no longer accepts a path. Use the dir option instead if you
|
||||
require tmp to create your temporary filesystem object in a different place than the
|
||||
default `tmp.tmpdir`.
|
||||
|
||||
```javascript
|
||||
var tmp = require('tmp');
|
||||
|
||||
tmp.dir({ template: 'tmp-XXXXXX' }, function _tempDirCreated(err, path) {
|
||||
if (err) throw err;
|
||||
|
||||
console.log('Dir: ', path);
|
||||
});
|
||||
```
|
||||
|
||||
### mkstemp like, synchronously
|
||||
|
||||
This will behave similarly to the asynchronous version.
|
||||
|
||||
```javascript
|
||||
var tmp = require('tmp');
|
||||
|
||||
var tmpobj = tmp.dirSync({ template: 'tmp-XXXXXX' });
|
||||
console.log('Dir: ', tmpobj.name);
|
||||
```
|
||||
|
||||
### Asynchronous filename generation
|
||||
|
||||
Using `tmpName()` you can create temporary file names asynchronously.
|
||||
The function accepts all standard options, e.g. `prefix`, `postfix`, `dir`, and so on.
|
||||
|
||||
You can also leave out the options altogether and just call the function with a callback as first parameter.
|
||||
|
||||
```javascript
|
||||
var tmp = require('tmp');
|
||||
|
||||
var options = {};
|
||||
|
||||
tmp.tmpName(options, function _tempNameGenerated(err, path) {
|
||||
if (err) throw err;
|
||||
|
||||
console.log('Created temporary filename: ', path);
|
||||
});
|
||||
```
|
||||
|
||||
### Synchronous filename generation
|
||||
|
||||
The `tmpNameSync()` function works similarly to `tmpName()`.
|
||||
Again, you can leave out the options altogether and just invoke the function without any parameters.
|
||||
|
||||
```javascript
|
||||
var tmp = require('tmp');
|
||||
var options = {};
|
||||
var tmpname = tmp.tmpNameSync(options);
|
||||
console.log('Created temporary filename: ', tmpname);
|
||||
```
|
||||
|
||||
## Graceful cleanup
|
||||
|
||||
One may want to cleanup the temporary files even when an uncaught exception
|
||||
occurs. To enforce this, you can call the `setGracefulCleanup()` method:
|
||||
|
||||
```javascript
|
||||
var tmp = require('tmp');
|
||||
|
||||
tmp.setGracefulCleanup();
|
||||
```
|
||||
|
||||
## Options
|
||||
|
||||
All options are optional :)
|
||||
|
||||
* `mode`: the file mode to create with, it fallbacks to `0600` on file creation and `0700` on directory creation
|
||||
* `prefix`: the optional prefix, fallbacks to `tmp-` if not provided
|
||||
* `postfix`: the optional postfix, fallbacks to `.tmp` on file creation
|
||||
* `template`: [`mkstemp`][3] like filename template, no default
|
||||
* `dir`: the optional temporary directory, fallbacks to system default (guesses from environment)
|
||||
* `tries`: how many times should the function try to get a unique filename before giving up, default `3`
|
||||
* `keep`: signals that the temporary file or directory should not be deleted on exit, default is `false`
|
||||
* In order to clean up, you will have to call the provided `cleanupCallback` function manually.
|
||||
* `unsafeCleanup`: recursively removes the created temporary directory, even when it's not empty. default is `false`
|
||||
|
||||
[1]: http://nodejs.org/
|
||||
[2]: https://www.npmjs.com/browse/depended/tmp
|
||||
[3]: http://www.kernel.org/doc/man-pages/online/pages/man3/mkstemp.3.html
|
||||
[4]: https://raszi.github.io/node-tmp/
|
||||
[5]: https://github.com/benjamingr/tmp-promise
|
||||
762
node_modules/tmp/lib/tmp.js
generated
vendored
Normal file
762
node_modules/tmp/lib/tmp.js
generated
vendored
Normal file
|
|
@ -0,0 +1,762 @@
|
|||
/*!
|
||||
* Tmp
|
||||
*
|
||||
* Copyright (c) 2011-2017 KARASZI Istvan <github@spam.raszi.hu>
|
||||
*
|
||||
* MIT Licensed
|
||||
*/
|
||||
|
||||
/*
|
||||
* Module dependencies.
|
||||
*/
|
||||
const fs = require('fs');
|
||||
const os = require('os');
|
||||
const path = require('path');
|
||||
const crypto = require('crypto');
|
||||
const _c = fs.constants && os.constants ?
|
||||
{ fs: fs.constants, os: os.constants } :
|
||||
process.binding('constants');
|
||||
const rimraf = require('rimraf');
|
||||
|
||||
/*
|
||||
* The working inner variables.
|
||||
*/
|
||||
const
|
||||
// the random characters to choose from
|
||||
RANDOM_CHARS = '0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz',
|
||||
|
||||
TEMPLATE_PATTERN = /XXXXXX/,
|
||||
|
||||
DEFAULT_TRIES = 3,
|
||||
|
||||
CREATE_FLAGS = (_c.O_CREAT || _c.fs.O_CREAT) | (_c.O_EXCL || _c.fs.O_EXCL) | (_c.O_RDWR || _c.fs.O_RDWR),
|
||||
|
||||
EBADF = _c.EBADF || _c.os.errno.EBADF,
|
||||
ENOENT = _c.ENOENT || _c.os.errno.ENOENT,
|
||||
|
||||
DIR_MODE = 448 /* 0o700 */,
|
||||
FILE_MODE = 384 /* 0o600 */,
|
||||
|
||||
EXIT = 'exit',
|
||||
|
||||
SIGINT = 'SIGINT',
|
||||
|
||||
// this will hold the objects need to be removed on exit
|
||||
_removeObjects = [];
|
||||
|
||||
var
|
||||
_gracefulCleanup = false;
|
||||
|
||||
/**
|
||||
* Random name generator based on crypto.
|
||||
* Adapted from http://blog.tompawlak.org/how-to-generate-random-values-nodejs-javascript
|
||||
*
|
||||
* @param {number} howMany
|
||||
* @returns {string} the generated random name
|
||||
* @private
|
||||
*/
|
||||
function _randomChars(howMany) {
|
||||
var
|
||||
value = [],
|
||||
rnd = null;
|
||||
|
||||
// make sure that we do not fail because we ran out of entropy
|
||||
try {
|
||||
rnd = crypto.randomBytes(howMany);
|
||||
} catch (e) {
|
||||
rnd = crypto.pseudoRandomBytes(howMany);
|
||||
}
|
||||
|
||||
for (var i = 0; i < howMany; i++) {
|
||||
value.push(RANDOM_CHARS[rnd[i] % RANDOM_CHARS.length]);
|
||||
}
|
||||
|
||||
return value.join('');
|
||||
}
|
||||
|
||||
/**
|
||||
* Checks whether the `obj` parameter is defined or not.
|
||||
*
|
||||
* @param {Object} obj
|
||||
* @returns {boolean} true if the object is undefined
|
||||
* @private
|
||||
*/
|
||||
function _isUndefined(obj) {
|
||||
return typeof obj === 'undefined';
|
||||
}
|
||||
|
||||
/**
|
||||
* Parses the function arguments.
|
||||
*
|
||||
* This function helps to have optional arguments.
|
||||
*
|
||||
* @param {(Options|Function)} options
|
||||
* @param {Function} callback
|
||||
* @returns {Array} parsed arguments
|
||||
* @private
|
||||
*/
|
||||
function _parseArguments(options, callback) {
|
||||
/* istanbul ignore else */
|
||||
if (typeof options === 'function') {
|
||||
return [{}, options];
|
||||
}
|
||||
|
||||
/* istanbul ignore else */
|
||||
if (_isUndefined(options)) {
|
||||
return [{}, callback];
|
||||
}
|
||||
|
||||
return [options, callback];
|
||||
}
|
||||
|
||||
/**
|
||||
* Generates a new temporary name.
|
||||
*
|
||||
* @param {Object} opts
|
||||
* @returns {string} the new random name according to opts
|
||||
* @private
|
||||
*/
|
||||
function _generateTmpName(opts) {
|
||||
|
||||
const tmpDir = _getTmpDir();
|
||||
|
||||
// fail early on missing tmp dir
|
||||
if (isBlank(opts.dir) && isBlank(tmpDir)) {
|
||||
throw new Error('No tmp dir specified');
|
||||
}
|
||||
|
||||
/* istanbul ignore else */
|
||||
if (!isBlank(opts.name)) {
|
||||
return path.join(opts.dir || tmpDir, opts.name);
|
||||
}
|
||||
|
||||
// mkstemps like template
|
||||
// opts.template has already been guarded in tmpName() below
|
||||
/* istanbul ignore else */
|
||||
if (opts.template) {
|
||||
var template = opts.template;
|
||||
// make sure that we prepend the tmp path if none was given
|
||||
/* istanbul ignore else */
|
||||
if (path.basename(template) === template)
|
||||
template = path.join(opts.dir || tmpDir, template);
|
||||
return template.replace(TEMPLATE_PATTERN, _randomChars(6));
|
||||
}
|
||||
|
||||
// prefix and postfix
|
||||
const name = [
|
||||
(isBlank(opts.prefix) ? 'tmp-' : opts.prefix),
|
||||
process.pid,
|
||||
_randomChars(12),
|
||||
(opts.postfix ? opts.postfix : '')
|
||||
].join('');
|
||||
|
||||
return path.join(opts.dir || tmpDir, name);
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets a temporary file name.
|
||||
*
|
||||
* @param {(Options|tmpNameCallback)} options options or callback
|
||||
* @param {?tmpNameCallback} callback the callback function
|
||||
*/
|
||||
function tmpName(options, callback) {
|
||||
var
|
||||
args = _parseArguments(options, callback),
|
||||
opts = args[0],
|
||||
cb = args[1],
|
||||
tries = !isBlank(opts.name) ? 1 : opts.tries || DEFAULT_TRIES;
|
||||
|
||||
/* istanbul ignore else */
|
||||
if (isNaN(tries) || tries < 0)
|
||||
return cb(new Error('Invalid tries'));
|
||||
|
||||
/* istanbul ignore else */
|
||||
if (opts.template && !opts.template.match(TEMPLATE_PATTERN))
|
||||
return cb(new Error('Invalid template provided'));
|
||||
|
||||
(function _getUniqueName() {
|
||||
try {
|
||||
const name = _generateTmpName(opts);
|
||||
|
||||
// check whether the path exists then retry if needed
|
||||
fs.stat(name, function (err) {
|
||||
/* istanbul ignore else */
|
||||
if (!err) {
|
||||
/* istanbul ignore else */
|
||||
if (tries-- > 0) return _getUniqueName();
|
||||
|
||||
return cb(new Error('Could not get a unique tmp filename, max tries reached ' + name));
|
||||
}
|
||||
|
||||
cb(null, name);
|
||||
});
|
||||
} catch (err) {
|
||||
cb(err);
|
||||
}
|
||||
}());
|
||||
}
|
||||
|
||||
/**
|
||||
* Synchronous version of tmpName.
|
||||
*
|
||||
* @param {Object} options
|
||||
* @returns {string} the generated random name
|
||||
* @throws {Error} if the options are invalid or could not generate a filename
|
||||
*/
|
||||
function tmpNameSync(options) {
|
||||
var
|
||||
args = _parseArguments(options),
|
||||
opts = args[0],
|
||||
tries = !isBlank(opts.name) ? 1 : opts.tries || DEFAULT_TRIES;
|
||||
|
||||
/* istanbul ignore else */
|
||||
if (isNaN(tries) || tries < 0)
|
||||
throw new Error('Invalid tries');
|
||||
|
||||
/* istanbul ignore else */
|
||||
if (opts.template && !opts.template.match(TEMPLATE_PATTERN))
|
||||
throw new Error('Invalid template provided');
|
||||
|
||||
do {
|
||||
const name = _generateTmpName(opts);
|
||||
try {
|
||||
fs.statSync(name);
|
||||
} catch (e) {
|
||||
return name;
|
||||
}
|
||||
} while (tries-- > 0);
|
||||
|
||||
throw new Error('Could not get a unique tmp filename, max tries reached');
|
||||
}
|
||||
|
||||
/**
|
||||
* Creates and opens a temporary file.
|
||||
*
|
||||
* @param {(Options|fileCallback)} options the config options or the callback function
|
||||
* @param {?fileCallback} callback
|
||||
*/
|
||||
function file(options, callback) {
|
||||
var
|
||||
args = _parseArguments(options, callback),
|
||||
opts = args[0],
|
||||
cb = args[1];
|
||||
|
||||
// gets a temporary filename
|
||||
tmpName(opts, function _tmpNameCreated(err, name) {
|
||||
/* istanbul ignore else */
|
||||
if (err) return cb(err);
|
||||
|
||||
// create and open the file
|
||||
fs.open(name, CREATE_FLAGS, opts.mode || FILE_MODE, function _fileCreated(err, fd) {
|
||||
/* istanbul ignore else */
|
||||
if (err) return cb(err);
|
||||
|
||||
if (opts.discardDescriptor) {
|
||||
return fs.close(fd, function _discardCallback(err) {
|
||||
/* istanbul ignore else */
|
||||
if (err) {
|
||||
// Low probability, and the file exists, so this could be
|
||||
// ignored. If it isn't we certainly need to unlink the
|
||||
// file, and if that fails too its error is more
|
||||
// important.
|
||||
try {
|
||||
fs.unlinkSync(name);
|
||||
} catch (e) {
|
||||
if (!isENOENT(e)) {
|
||||
err = e;
|
||||
}
|
||||
}
|
||||
return cb(err);
|
||||
}
|
||||
cb(null, name, undefined, _prepareTmpFileRemoveCallback(name, -1, opts));
|
||||
});
|
||||
}
|
||||
/* istanbul ignore else */
|
||||
if (opts.detachDescriptor) {
|
||||
return cb(null, name, fd, _prepareTmpFileRemoveCallback(name, -1, opts));
|
||||
}
|
||||
cb(null, name, fd, _prepareTmpFileRemoveCallback(name, fd, opts));
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* Synchronous version of file.
|
||||
*
|
||||
* @param {Options} options
|
||||
* @returns {FileSyncObject} object consists of name, fd and removeCallback
|
||||
* @throws {Error} if cannot create a file
|
||||
*/
|
||||
function fileSync(options) {
|
||||
var
|
||||
args = _parseArguments(options),
|
||||
opts = args[0];
|
||||
|
||||
const discardOrDetachDescriptor = opts.discardDescriptor || opts.detachDescriptor;
|
||||
const name = tmpNameSync(opts);
|
||||
var fd = fs.openSync(name, CREATE_FLAGS, opts.mode || FILE_MODE);
|
||||
/* istanbul ignore else */
|
||||
if (opts.discardDescriptor) {
|
||||
fs.closeSync(fd);
|
||||
fd = undefined;
|
||||
}
|
||||
|
||||
return {
|
||||
name: name,
|
||||
fd: fd,
|
||||
removeCallback: _prepareTmpFileRemoveCallback(name, discardOrDetachDescriptor ? -1 : fd, opts)
|
||||
};
|
||||
}
|
||||
|
||||
/**
|
||||
* Creates a temporary directory.
|
||||
*
|
||||
* @param {(Options|dirCallback)} options the options or the callback function
|
||||
* @param {?dirCallback} callback
|
||||
*/
|
||||
function dir(options, callback) {
|
||||
var
|
||||
args = _parseArguments(options, callback),
|
||||
opts = args[0],
|
||||
cb = args[1];
|
||||
|
||||
// gets a temporary filename
|
||||
tmpName(opts, function _tmpNameCreated(err, name) {
|
||||
/* istanbul ignore else */
|
||||
if (err) return cb(err);
|
||||
|
||||
// create the directory
|
||||
fs.mkdir(name, opts.mode || DIR_MODE, function _dirCreated(err) {
|
||||
/* istanbul ignore else */
|
||||
if (err) return cb(err);
|
||||
|
||||
cb(null, name, _prepareTmpDirRemoveCallback(name, opts));
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* Synchronous version of dir.
|
||||
*
|
||||
* @param {Options} options
|
||||
* @returns {DirSyncObject} object consists of name and removeCallback
|
||||
* @throws {Error} if it cannot create a directory
|
||||
*/
|
||||
function dirSync(options) {
|
||||
var
|
||||
args = _parseArguments(options),
|
||||
opts = args[0];
|
||||
|
||||
const name = tmpNameSync(opts);
|
||||
fs.mkdirSync(name, opts.mode || DIR_MODE);
|
||||
|
||||
return {
|
||||
name: name,
|
||||
removeCallback: _prepareTmpDirRemoveCallback(name, opts)
|
||||
};
|
||||
}
|
||||
|
||||
/**
|
||||
* Removes files asynchronously.
|
||||
*
|
||||
* @param {Object} fdPath
|
||||
* @param {Function} next
|
||||
* @private
|
||||
*/
|
||||
function _removeFileAsync(fdPath, next) {
|
||||
const _handler = function (err) {
|
||||
if (err && !isENOENT(err)) {
|
||||
// reraise any unanticipated error
|
||||
return next(err);
|
||||
}
|
||||
next();
|
||||
}
|
||||
|
||||
if (0 <= fdPath[0])
|
||||
fs.close(fdPath[0], function (err) {
|
||||
fs.unlink(fdPath[1], _handler);
|
||||
});
|
||||
else fs.unlink(fdPath[1], _handler);
|
||||
}
|
||||
|
||||
/**
|
||||
* Removes files synchronously.
|
||||
*
|
||||
* @param {Object} fdPath
|
||||
* @private
|
||||
*/
|
||||
function _removeFileSync(fdPath) {
|
||||
try {
|
||||
if (0 <= fdPath[0]) fs.closeSync(fdPath[0]);
|
||||
} catch (e) {
|
||||
// reraise any unanticipated error
|
||||
if (!isEBADF(e) && !isENOENT(e)) throw e;
|
||||
} finally {
|
||||
try {
|
||||
fs.unlinkSync(fdPath[1]);
|
||||
}
|
||||
catch (e) {
|
||||
// reraise any unanticipated error
|
||||
if (!isENOENT(e)) throw e;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Prepares the callback for removal of the temporary file.
|
||||
*
|
||||
* @param {string} name the path of the file
|
||||
* @param {number} fd file descriptor
|
||||
* @param {Object} opts
|
||||
* @returns {fileCallback}
|
||||
* @private
|
||||
*/
|
||||
function _prepareTmpFileRemoveCallback(name, fd, opts) {
|
||||
const removeCallbackSync = _prepareRemoveCallback(_removeFileSync, [fd, name]);
|
||||
const removeCallback = _prepareRemoveCallback(_removeFileAsync, [fd, name], removeCallbackSync);
|
||||
|
||||
if (!opts.keep) _removeObjects.unshift(removeCallbackSync);
|
||||
|
||||
return removeCallback;
|
||||
}
|
||||
|
||||
/**
|
||||
* Simple wrapper for rimraf.
|
||||
*
|
||||
* @param {string} dirPath
|
||||
* @param {Function} next
|
||||
* @private
|
||||
*/
|
||||
function _rimrafRemoveDirWrapper(dirPath, next) {
|
||||
rimraf(dirPath, next);
|
||||
}
|
||||
|
||||
/**
|
||||
* Simple wrapper for rimraf.sync.
|
||||
*
|
||||
* @param {string} dirPath
|
||||
* @private
|
||||
*/
|
||||
function _rimrafRemoveDirSyncWrapper(dirPath, next) {
|
||||
try {
|
||||
return next(null, rimraf.sync(dirPath));
|
||||
} catch (err) {
|
||||
return next(err);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Prepares the callback for removal of the temporary directory.
|
||||
*
|
||||
* @param {string} name
|
||||
* @param {Object} opts
|
||||
* @returns {Function} the callback
|
||||
* @private
|
||||
*/
|
||||
function _prepareTmpDirRemoveCallback(name, opts) {
|
||||
const removeFunction = opts.unsafeCleanup ? _rimrafRemoveDirWrapper : fs.rmdir.bind(fs);
|
||||
const removeFunctionSync = opts.unsafeCleanup ? _rimrafRemoveDirSyncWrapper : fs.rmdirSync.bind(fs);
|
||||
const removeCallbackSync = _prepareRemoveCallback(removeFunctionSync, name);
|
||||
const removeCallback = _prepareRemoveCallback(removeFunction, name, removeCallbackSync);
|
||||
if (!opts.keep) _removeObjects.unshift(removeCallbackSync);
|
||||
|
||||
return removeCallback;
|
||||
}
|
||||
|
||||
/**
|
||||
* Creates a guarded function wrapping the removeFunction call.
|
||||
*
|
||||
* @param {Function} removeFunction
|
||||
* @param {Object} arg
|
||||
* @returns {Function}
|
||||
* @private
|
||||
*/
|
||||
function _prepareRemoveCallback(removeFunction, arg, cleanupCallbackSync) {
|
||||
var called = false;
|
||||
|
||||
return function _cleanupCallback(next) {
|
||||
next = next || function () {};
|
||||
if (!called) {
|
||||
const toRemove = cleanupCallbackSync || _cleanupCallback;
|
||||
const index = _removeObjects.indexOf(toRemove);
|
||||
/* istanbul ignore else */
|
||||
if (index >= 0) _removeObjects.splice(index, 1);
|
||||
|
||||
called = true;
|
||||
// sync?
|
||||
if (removeFunction.length === 1) {
|
||||
try {
|
||||
removeFunction(arg);
|
||||
return next(null);
|
||||
}
|
||||
catch (err) {
|
||||
// if no next is provided and since we are
|
||||
// in silent cleanup mode on process exit,
|
||||
// we will ignore the error
|
||||
return next(err);
|
||||
}
|
||||
} else return removeFunction(arg, next);
|
||||
} else return next(new Error('cleanup callback has already been called'));
|
||||
};
|
||||
}
|
||||
|
||||
/**
|
||||
* The garbage collector.
|
||||
*
|
||||
* @private
|
||||
*/
|
||||
function _garbageCollector() {
|
||||
/* istanbul ignore else */
|
||||
if (!_gracefulCleanup) return;
|
||||
|
||||
// the function being called removes itself from _removeObjects,
|
||||
// loop until _removeObjects is empty
|
||||
while (_removeObjects.length) {
|
||||
try {
|
||||
_removeObjects[0]();
|
||||
} catch (e) {
|
||||
// already removed?
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Helper for testing against EBADF to compensate changes made to Node 7.x under Windows.
|
||||
*/
|
||||
function isEBADF(error) {
|
||||
return isExpectedError(error, -EBADF, 'EBADF');
|
||||
}
|
||||
|
||||
/**
|
||||
* Helper for testing against ENOENT to compensate changes made to Node 7.x under Windows.
|
||||
*/
|
||||
function isENOENT(error) {
|
||||
return isExpectedError(error, -ENOENT, 'ENOENT');
|
||||
}
|
||||
|
||||
/**
|
||||
* Helper to determine whether the expected error code matches the actual code and errno,
|
||||
* which will differ between the supported node versions.
|
||||
*
|
||||
* - Node >= 7.0:
|
||||
* error.code {string}
|
||||
* error.errno {string|number} any numerical value will be negated
|
||||
*
|
||||
* - Node >= 6.0 < 7.0:
|
||||
* error.code {string}
|
||||
* error.errno {number} negated
|
||||
*
|
||||
* - Node >= 4.0 < 6.0: introduces SystemError
|
||||
* error.code {string}
|
||||
* error.errno {number} negated
|
||||
*
|
||||
* - Node >= 0.10 < 4.0:
|
||||
* error.code {number} negated
|
||||
* error.errno n/a
|
||||
*/
|
||||
function isExpectedError(error, code, errno) {
|
||||
return error.code === code || error.code === errno;
|
||||
}
|
||||
|
||||
/**
|
||||
* Helper which determines whether a string s is blank, that is undefined, or empty or null.
|
||||
*
|
||||
* @private
|
||||
* @param {string} s
|
||||
* @returns {Boolean} true whether the string s is blank, false otherwise
|
||||
*/
|
||||
function isBlank(s) {
|
||||
return s === null || s === undefined || !s.trim();
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the graceful cleanup.
|
||||
*/
|
||||
function setGracefulCleanup() {
|
||||
_gracefulCleanup = true;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the currently configured tmp dir from os.tmpdir().
|
||||
*
|
||||
* @private
|
||||
* @returns {string} the currently configured tmp dir
|
||||
*/
|
||||
function _getTmpDir() {
|
||||
return os.tmpdir();
|
||||
}
|
||||
|
||||
/**
|
||||
* If there are multiple different versions of tmp in place, make sure that
|
||||
* we recognize the old listeners.
|
||||
*
|
||||
* @param {Function} listener
|
||||
* @private
|
||||
* @returns {Boolean} true whether listener is a legacy listener
|
||||
*/
|
||||
function _is_legacy_listener(listener) {
|
||||
return (listener.name === '_exit' || listener.name === '_uncaughtExceptionThrown')
|
||||
&& listener.toString().indexOf('_garbageCollector();') > -1;
|
||||
}
|
||||
|
||||
/**
|
||||
* Safely install SIGINT listener.
|
||||
*
|
||||
* NOTE: this will only work on OSX and Linux.
|
||||
*
|
||||
* @private
|
||||
*/
|
||||
function _safely_install_sigint_listener() {
|
||||
|
||||
const listeners = process.listeners(SIGINT);
|
||||
const existingListeners = [];
|
||||
for (let i = 0, length = listeners.length; i < length; i++) {
|
||||
const lstnr = listeners[i];
|
||||
/* istanbul ignore else */
|
||||
if (lstnr.name === '_tmp$sigint_listener') {
|
||||
existingListeners.push(lstnr);
|
||||
process.removeListener(SIGINT, lstnr);
|
||||
}
|
||||
}
|
||||
process.on(SIGINT, function _tmp$sigint_listener(doExit) {
|
||||
for (let i = 0, length = existingListeners.length; i < length; i++) {
|
||||
// let the existing listener do the garbage collection (e.g. jest sandbox)
|
||||
try {
|
||||
existingListeners[i](false);
|
||||
} catch (err) {
|
||||
// ignore
|
||||
}
|
||||
}
|
||||
try {
|
||||
// force the garbage collector even it is called again in the exit listener
|
||||
_garbageCollector();
|
||||
} finally {
|
||||
if (!!doExit) {
|
||||
process.exit(0);
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* Safely install process exit listener.
|
||||
*
|
||||
* @private
|
||||
*/
|
||||
function _safely_install_exit_listener() {
|
||||
const listeners = process.listeners(EXIT);
|
||||
|
||||
// collect any existing listeners
|
||||
const existingListeners = [];
|
||||
for (let i = 0, length = listeners.length; i < length; i++) {
|
||||
const lstnr = listeners[i];
|
||||
/* istanbul ignore else */
|
||||
// TODO: remove support for legacy listeners once release 1.0.0 is out
|
||||
if (lstnr.name === '_tmp$safe_listener' || _is_legacy_listener(lstnr)) {
|
||||
// we must forget about the uncaughtException listener, hopefully it is ours
|
||||
if (lstnr.name !== '_uncaughtExceptionThrown') {
|
||||
existingListeners.push(lstnr);
|
||||
}
|
||||
process.removeListener(EXIT, lstnr);
|
||||
}
|
||||
}
|
||||
// TODO: what was the data parameter good for?
|
||||
process.addListener(EXIT, function _tmp$safe_listener(data) {
|
||||
for (let i = 0, length = existingListeners.length; i < length; i++) {
|
||||
// let the existing listener do the garbage collection (e.g. jest sandbox)
|
||||
try {
|
||||
existingListeners[i](data);
|
||||
} catch (err) {
|
||||
// ignore
|
||||
}
|
||||
}
|
||||
_garbageCollector();
|
||||
});
|
||||
}
|
||||
|
||||
_safely_install_exit_listener();
|
||||
_safely_install_sigint_listener();
|
||||
|
||||
/**
|
||||
* Configuration options.
|
||||
*
|
||||
* @typedef {Object} Options
|
||||
* @property {?number} tries the number of tries before give up the name generation
|
||||
* @property {?string} template the "mkstemp" like filename template
|
||||
* @property {?string} name fix name
|
||||
* @property {?string} dir the tmp directory to use
|
||||
* @property {?string} prefix prefix for the generated name
|
||||
* @property {?string} postfix postfix for the generated name
|
||||
* @property {?boolean} unsafeCleanup recursively removes the created temporary directory, even when it's not empty
|
||||
*/
|
||||
|
||||
/**
|
||||
* @typedef {Object} FileSyncObject
|
||||
* @property {string} name the name of the file
|
||||
* @property {string} fd the file descriptor
|
||||
* @property {fileCallback} removeCallback the callback function to remove the file
|
||||
*/
|
||||
|
||||
/**
|
||||
* @typedef {Object} DirSyncObject
|
||||
* @property {string} name the name of the directory
|
||||
* @property {fileCallback} removeCallback the callback function to remove the directory
|
||||
*/
|
||||
|
||||
/**
|
||||
* @callback tmpNameCallback
|
||||
* @param {?Error} err the error object if anything goes wrong
|
||||
* @param {string} name the temporary file name
|
||||
*/
|
||||
|
||||
/**
|
||||
* @callback fileCallback
|
||||
* @param {?Error} err the error object if anything goes wrong
|
||||
* @param {string} name the temporary file name
|
||||
* @param {number} fd the file descriptor
|
||||
* @param {cleanupCallback} fn the cleanup callback function
|
||||
*/
|
||||
|
||||
/**
|
||||
* @callback dirCallback
|
||||
* @param {?Error} err the error object if anything goes wrong
|
||||
* @param {string} name the temporary file name
|
||||
* @param {cleanupCallback} fn the cleanup callback function
|
||||
*/
|
||||
|
||||
/**
|
||||
* Removes the temporary created file or directory.
|
||||
*
|
||||
* @callback cleanupCallback
|
||||
* @param {simpleCallback} [next] function to call after entry was removed
|
||||
*/
|
||||
|
||||
/**
|
||||
* Callback function for function composition.
|
||||
* @see {@link https://github.com/raszi/node-tmp/issues/57|raszi/node-tmp#57}
|
||||
*
|
||||
* @callback simpleCallback
|
||||
*/
|
||||
|
||||
// exporting all the needed methods
|
||||
|
||||
// evaluate os.tmpdir() lazily, mainly for simplifying testing but it also will
|
||||
// allow users to reconfigure the temporary directory
|
||||
Object.defineProperty(module.exports, 'tmpdir', {
|
||||
enumerable: true,
|
||||
configurable: false,
|
||||
get: function () {
|
||||
return _getTmpDir();
|
||||
}
|
||||
});
|
||||
|
||||
module.exports.dir = dir;
|
||||
module.exports.dirSync = dirSync;
|
||||
|
||||
module.exports.file = file;
|
||||
module.exports.fileSync = fileSync;
|
||||
|
||||
module.exports.tmpName = tmpName;
|
||||
module.exports.tmpNameSync = tmpNameSync;
|
||||
|
||||
module.exports.setGracefulCleanup = setGracefulCleanup;
|
||||
1
node_modules/tmp/node_modules/.bin/rimraf
generated
vendored
Symbolic link
1
node_modules/tmp/node_modules/.bin/rimraf
generated
vendored
Symbolic link
|
|
@ -0,0 +1 @@
|
|||
../rimraf/bin.js
|
||||
15
node_modules/tmp/node_modules/rimraf/LICENSE
generated
vendored
Normal file
15
node_modules/tmp/node_modules/rimraf/LICENSE
generated
vendored
Normal file
|
|
@ -0,0 +1,15 @@
|
|||
The ISC License
|
||||
|
||||
Copyright (c) Isaac Z. Schlueter and Contributors
|
||||
|
||||
Permission to use, copy, modify, and/or distribute this software for any
|
||||
purpose with or without fee is hereby granted, provided that the above
|
||||
copyright notice and this permission notice appear in all copies.
|
||||
|
||||
THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
|
||||
WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
|
||||
MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
|
||||
ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
|
||||
WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
|
||||
ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR
|
||||
IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
|
||||
101
node_modules/tmp/node_modules/rimraf/README.md
generated
vendored
Normal file
101
node_modules/tmp/node_modules/rimraf/README.md
generated
vendored
Normal file
|
|
@ -0,0 +1,101 @@
|
|||
[](https://travis-ci.org/isaacs/rimraf) [](https://david-dm.org/isaacs/rimraf) [](https://david-dm.org/isaacs/rimraf#info=devDependencies)
|
||||
|
||||
The [UNIX command](http://en.wikipedia.org/wiki/Rm_(Unix)) `rm -rf` for node.
|
||||
|
||||
Install with `npm install rimraf`, or just drop rimraf.js somewhere.
|
||||
|
||||
## API
|
||||
|
||||
`rimraf(f, [opts], callback)`
|
||||
|
||||
The first parameter will be interpreted as a globbing pattern for files. If you
|
||||
want to disable globbing you can do so with `opts.disableGlob` (defaults to
|
||||
`false`). This might be handy, for instance, if you have filenames that contain
|
||||
globbing wildcard characters.
|
||||
|
||||
The callback will be called with an error if there is one. Certain
|
||||
errors are handled for you:
|
||||
|
||||
* Windows: `EBUSY` and `ENOTEMPTY` - rimraf will back off a maximum of
|
||||
`opts.maxBusyTries` times before giving up, adding 100ms of wait
|
||||
between each attempt. The default `maxBusyTries` is 3.
|
||||
* `ENOENT` - If the file doesn't exist, rimraf will return
|
||||
successfully, since your desired outcome is already the case.
|
||||
* `EMFILE` - Since `readdir` requires opening a file descriptor, it's
|
||||
possible to hit `EMFILE` if too many file descriptors are in use.
|
||||
In the sync case, there's nothing to be done for this. But in the
|
||||
async case, rimraf will gradually back off with timeouts up to
|
||||
`opts.emfileWait` ms, which defaults to 1000.
|
||||
|
||||
## options
|
||||
|
||||
* unlink, chmod, stat, lstat, rmdir, readdir,
|
||||
unlinkSync, chmodSync, statSync, lstatSync, rmdirSync, readdirSync
|
||||
|
||||
In order to use a custom file system library, you can override
|
||||
specific fs functions on the options object.
|
||||
|
||||
If any of these functions are present on the options object, then
|
||||
the supplied function will be used instead of the default fs
|
||||
method.
|
||||
|
||||
Sync methods are only relevant for `rimraf.sync()`, of course.
|
||||
|
||||
For example:
|
||||
|
||||
```javascript
|
||||
var myCustomFS = require('some-custom-fs')
|
||||
|
||||
rimraf('some-thing', myCustomFS, callback)
|
||||
```
|
||||
|
||||
* maxBusyTries
|
||||
|
||||
If an `EBUSY`, `ENOTEMPTY`, or `EPERM` error code is encountered
|
||||
on Windows systems, then rimraf will retry with a linear backoff
|
||||
wait of 100ms longer on each try. The default maxBusyTries is 3.
|
||||
|
||||
Only relevant for async usage.
|
||||
|
||||
* emfileWait
|
||||
|
||||
If an `EMFILE` error is encountered, then rimraf will retry
|
||||
repeatedly with a linear backoff of 1ms longer on each try, until
|
||||
the timeout counter hits this max. The default limit is 1000.
|
||||
|
||||
If you repeatedly encounter `EMFILE` errors, then consider using
|
||||
[graceful-fs](http://npm.im/graceful-fs) in your program.
|
||||
|
||||
Only relevant for async usage.
|
||||
|
||||
* glob
|
||||
|
||||
Set to `false` to disable [glob](http://npm.im/glob) pattern
|
||||
matching.
|
||||
|
||||
Set to an object to pass options to the glob module. The default
|
||||
glob options are `{ nosort: true, silent: true }`.
|
||||
|
||||
Glob version 6 is used in this module.
|
||||
|
||||
Relevant for both sync and async usage.
|
||||
|
||||
* disableGlob
|
||||
|
||||
Set to any non-falsey value to disable globbing entirely.
|
||||
(Equivalent to setting `glob: false`.)
|
||||
|
||||
## rimraf.sync
|
||||
|
||||
It can remove stuff synchronously, too. But that's not so good. Use
|
||||
the async API. It's better.
|
||||
|
||||
## CLI
|
||||
|
||||
If installed with `npm install rimraf -g` it can be used as a global
|
||||
command `rimraf <path> [<path> ...]` which is useful for cross platform support.
|
||||
|
||||
## mkdirp
|
||||
|
||||
If you need to create a directory recursively, check out
|
||||
[mkdirp](https://github.com/substack/node-mkdirp).
|
||||
50
node_modules/tmp/node_modules/rimraf/bin.js
generated
vendored
Executable file
50
node_modules/tmp/node_modules/rimraf/bin.js
generated
vendored
Executable file
|
|
@ -0,0 +1,50 @@
|
|||
#!/usr/bin/env node
|
||||
|
||||
var rimraf = require('./')
|
||||
|
||||
var help = false
|
||||
var dashdash = false
|
||||
var noglob = false
|
||||
var args = process.argv.slice(2).filter(function(arg) {
|
||||
if (dashdash)
|
||||
return !!arg
|
||||
else if (arg === '--')
|
||||
dashdash = true
|
||||
else if (arg === '--no-glob' || arg === '-G')
|
||||
noglob = true
|
||||
else if (arg === '--glob' || arg === '-g')
|
||||
noglob = false
|
||||
else if (arg.match(/^(-+|\/)(h(elp)?|\?)$/))
|
||||
help = true
|
||||
else
|
||||
return !!arg
|
||||
})
|
||||
|
||||
if (help || args.length === 0) {
|
||||
// If they didn't ask for help, then this is not a "success"
|
||||
var log = help ? console.log : console.error
|
||||
log('Usage: rimraf <path> [<path> ...]')
|
||||
log('')
|
||||
log(' Deletes all files and folders at "path" recursively.')
|
||||
log('')
|
||||
log('Options:')
|
||||
log('')
|
||||
log(' -h, --help Display this usage info')
|
||||
log(' -G, --no-glob Do not expand glob patterns in arguments')
|
||||
log(' -g, --glob Expand glob patterns in arguments (default)')
|
||||
process.exit(help ? 0 : 1)
|
||||
} else
|
||||
go(0)
|
||||
|
||||
function go (n) {
|
||||
if (n >= args.length)
|
||||
return
|
||||
var options = {}
|
||||
if (noglob)
|
||||
options = { glob: false }
|
||||
rimraf(args[n], options, function (er) {
|
||||
if (er)
|
||||
throw er
|
||||
go(n+1)
|
||||
})
|
||||
}
|
||||
29
node_modules/tmp/node_modules/rimraf/package.json
generated
vendored
Normal file
29
node_modules/tmp/node_modules/rimraf/package.json
generated
vendored
Normal file
|
|
@ -0,0 +1,29 @@
|
|||
{
|
||||
"name": "rimraf",
|
||||
"version": "2.7.1",
|
||||
"main": "rimraf.js",
|
||||
"description": "A deep deletion module for node (like `rm -rf`)",
|
||||
"author": "Isaac Z. Schlueter <i@izs.me> (http://blog.izs.me/)",
|
||||
"license": "ISC",
|
||||
"repository": "git://github.com/isaacs/rimraf.git",
|
||||
"scripts": {
|
||||
"preversion": "npm test",
|
||||
"postversion": "npm publish",
|
||||
"postpublish": "git push origin --all; git push origin --tags",
|
||||
"test": "tap test/*.js"
|
||||
},
|
||||
"bin": "./bin.js",
|
||||
"dependencies": {
|
||||
"glob": "^7.1.3"
|
||||
},
|
||||
"files": [
|
||||
"LICENSE",
|
||||
"README.md",
|
||||
"bin.js",
|
||||
"rimraf.js"
|
||||
],
|
||||
"devDependencies": {
|
||||
"mkdirp": "^0.5.1",
|
||||
"tap": "^12.1.1"
|
||||
}
|
||||
}
|
||||
372
node_modules/tmp/node_modules/rimraf/rimraf.js
generated
vendored
Normal file
372
node_modules/tmp/node_modules/rimraf/rimraf.js
generated
vendored
Normal file
|
|
@ -0,0 +1,372 @@
|
|||
module.exports = rimraf
|
||||
rimraf.sync = rimrafSync
|
||||
|
||||
var assert = require("assert")
|
||||
var path = require("path")
|
||||
var fs = require("fs")
|
||||
var glob = undefined
|
||||
try {
|
||||
glob = require("glob")
|
||||
} catch (_err) {
|
||||
// treat glob as optional.
|
||||
}
|
||||
var _0666 = parseInt('666', 8)
|
||||
|
||||
var defaultGlobOpts = {
|
||||
nosort: true,
|
||||
silent: true
|
||||
}
|
||||
|
||||
// for EMFILE handling
|
||||
var timeout = 0
|
||||
|
||||
var isWindows = (process.platform === "win32")
|
||||
|
||||
function defaults (options) {
|
||||
var methods = [
|
||||
'unlink',
|
||||
'chmod',
|
||||
'stat',
|
||||
'lstat',
|
||||
'rmdir',
|
||||
'readdir'
|
||||
]
|
||||
methods.forEach(function(m) {
|
||||
options[m] = options[m] || fs[m]
|
||||
m = m + 'Sync'
|
||||
options[m] = options[m] || fs[m]
|
||||
})
|
||||
|
||||
options.maxBusyTries = options.maxBusyTries || 3
|
||||
options.emfileWait = options.emfileWait || 1000
|
||||
if (options.glob === false) {
|
||||
options.disableGlob = true
|
||||
}
|
||||
if (options.disableGlob !== true && glob === undefined) {
|
||||
throw Error('glob dependency not found, set `options.disableGlob = true` if intentional')
|
||||
}
|
||||
options.disableGlob = options.disableGlob || false
|
||||
options.glob = options.glob || defaultGlobOpts
|
||||
}
|
||||
|
||||
function rimraf (p, options, cb) {
|
||||
if (typeof options === 'function') {
|
||||
cb = options
|
||||
options = {}
|
||||
}
|
||||
|
||||
assert(p, 'rimraf: missing path')
|
||||
assert.equal(typeof p, 'string', 'rimraf: path should be a string')
|
||||
assert.equal(typeof cb, 'function', 'rimraf: callback function required')
|
||||
assert(options, 'rimraf: invalid options argument provided')
|
||||
assert.equal(typeof options, 'object', 'rimraf: options should be object')
|
||||
|
||||
defaults(options)
|
||||
|
||||
var busyTries = 0
|
||||
var errState = null
|
||||
var n = 0
|
||||
|
||||
if (options.disableGlob || !glob.hasMagic(p))
|
||||
return afterGlob(null, [p])
|
||||
|
||||
options.lstat(p, function (er, stat) {
|
||||
if (!er)
|
||||
return afterGlob(null, [p])
|
||||
|
||||
glob(p, options.glob, afterGlob)
|
||||
})
|
||||
|
||||
function next (er) {
|
||||
errState = errState || er
|
||||
if (--n === 0)
|
||||
cb(errState)
|
||||
}
|
||||
|
||||
function afterGlob (er, results) {
|
||||
if (er)
|
||||
return cb(er)
|
||||
|
||||
n = results.length
|
||||
if (n === 0)
|
||||
return cb()
|
||||
|
||||
results.forEach(function (p) {
|
||||
rimraf_(p, options, function CB (er) {
|
||||
if (er) {
|
||||
if ((er.code === "EBUSY" || er.code === "ENOTEMPTY" || er.code === "EPERM") &&
|
||||
busyTries < options.maxBusyTries) {
|
||||
busyTries ++
|
||||
var time = busyTries * 100
|
||||
// try again, with the same exact callback as this one.
|
||||
return setTimeout(function () {
|
||||
rimraf_(p, options, CB)
|
||||
}, time)
|
||||
}
|
||||
|
||||
// this one won't happen if graceful-fs is used.
|
||||
if (er.code === "EMFILE" && timeout < options.emfileWait) {
|
||||
return setTimeout(function () {
|
||||
rimraf_(p, options, CB)
|
||||
}, timeout ++)
|
||||
}
|
||||
|
||||
// already gone
|
||||
if (er.code === "ENOENT") er = null
|
||||
}
|
||||
|
||||
timeout = 0
|
||||
next(er)
|
||||
})
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
// Two possible strategies.
|
||||
// 1. Assume it's a file. unlink it, then do the dir stuff on EPERM or EISDIR
|
||||
// 2. Assume it's a directory. readdir, then do the file stuff on ENOTDIR
|
||||
//
|
||||
// Both result in an extra syscall when you guess wrong. However, there
|
||||
// are likely far more normal files in the world than directories. This
|
||||
// is based on the assumption that a the average number of files per
|
||||
// directory is >= 1.
|
||||
//
|
||||
// If anyone ever complains about this, then I guess the strategy could
|
||||
// be made configurable somehow. But until then, YAGNI.
|
||||
function rimraf_ (p, options, cb) {
|
||||
assert(p)
|
||||
assert(options)
|
||||
assert(typeof cb === 'function')
|
||||
|
||||
// sunos lets the root user unlink directories, which is... weird.
|
||||
// so we have to lstat here and make sure it's not a dir.
|
||||
options.lstat(p, function (er, st) {
|
||||
if (er && er.code === "ENOENT")
|
||||
return cb(null)
|
||||
|
||||
// Windows can EPERM on stat. Life is suffering.
|
||||
if (er && er.code === "EPERM" && isWindows)
|
||||
fixWinEPERM(p, options, er, cb)
|
||||
|
||||
if (st && st.isDirectory())
|
||||
return rmdir(p, options, er, cb)
|
||||
|
||||
options.unlink(p, function (er) {
|
||||
if (er) {
|
||||
if (er.code === "ENOENT")
|
||||
return cb(null)
|
||||
if (er.code === "EPERM")
|
||||
return (isWindows)
|
||||
? fixWinEPERM(p, options, er, cb)
|
||||
: rmdir(p, options, er, cb)
|
||||
if (er.code === "EISDIR")
|
||||
return rmdir(p, options, er, cb)
|
||||
}
|
||||
return cb(er)
|
||||
})
|
||||
})
|
||||
}
|
||||
|
||||
function fixWinEPERM (p, options, er, cb) {
|
||||
assert(p)
|
||||
assert(options)
|
||||
assert(typeof cb === 'function')
|
||||
if (er)
|
||||
assert(er instanceof Error)
|
||||
|
||||
options.chmod(p, _0666, function (er2) {
|
||||
if (er2)
|
||||
cb(er2.code === "ENOENT" ? null : er)
|
||||
else
|
||||
options.stat(p, function(er3, stats) {
|
||||
if (er3)
|
||||
cb(er3.code === "ENOENT" ? null : er)
|
||||
else if (stats.isDirectory())
|
||||
rmdir(p, options, er, cb)
|
||||
else
|
||||
options.unlink(p, cb)
|
||||
})
|
||||
})
|
||||
}
|
||||
|
||||
function fixWinEPERMSync (p, options, er) {
|
||||
assert(p)
|
||||
assert(options)
|
||||
if (er)
|
||||
assert(er instanceof Error)
|
||||
|
||||
try {
|
||||
options.chmodSync(p, _0666)
|
||||
} catch (er2) {
|
||||
if (er2.code === "ENOENT")
|
||||
return
|
||||
else
|
||||
throw er
|
||||
}
|
||||
|
||||
try {
|
||||
var stats = options.statSync(p)
|
||||
} catch (er3) {
|
||||
if (er3.code === "ENOENT")
|
||||
return
|
||||
else
|
||||
throw er
|
||||
}
|
||||
|
||||
if (stats.isDirectory())
|
||||
rmdirSync(p, options, er)
|
||||
else
|
||||
options.unlinkSync(p)
|
||||
}
|
||||
|
||||
function rmdir (p, options, originalEr, cb) {
|
||||
assert(p)
|
||||
assert(options)
|
||||
if (originalEr)
|
||||
assert(originalEr instanceof Error)
|
||||
assert(typeof cb === 'function')
|
||||
|
||||
// try to rmdir first, and only readdir on ENOTEMPTY or EEXIST (SunOS)
|
||||
// if we guessed wrong, and it's not a directory, then
|
||||
// raise the original error.
|
||||
options.rmdir(p, function (er) {
|
||||
if (er && (er.code === "ENOTEMPTY" || er.code === "EEXIST" || er.code === "EPERM"))
|
||||
rmkids(p, options, cb)
|
||||
else if (er && er.code === "ENOTDIR")
|
||||
cb(originalEr)
|
||||
else
|
||||
cb(er)
|
||||
})
|
||||
}
|
||||
|
||||
function rmkids(p, options, cb) {
|
||||
assert(p)
|
||||
assert(options)
|
||||
assert(typeof cb === 'function')
|
||||
|
||||
options.readdir(p, function (er, files) {
|
||||
if (er)
|
||||
return cb(er)
|
||||
var n = files.length
|
||||
if (n === 0)
|
||||
return options.rmdir(p, cb)
|
||||
var errState
|
||||
files.forEach(function (f) {
|
||||
rimraf(path.join(p, f), options, function (er) {
|
||||
if (errState)
|
||||
return
|
||||
if (er)
|
||||
return cb(errState = er)
|
||||
if (--n === 0)
|
||||
options.rmdir(p, cb)
|
||||
})
|
||||
})
|
||||
})
|
||||
}
|
||||
|
||||
// this looks simpler, and is strictly *faster*, but will
|
||||
// tie up the JavaScript thread and fail on excessively
|
||||
// deep directory trees.
|
||||
function rimrafSync (p, options) {
|
||||
options = options || {}
|
||||
defaults(options)
|
||||
|
||||
assert(p, 'rimraf: missing path')
|
||||
assert.equal(typeof p, 'string', 'rimraf: path should be a string')
|
||||
assert(options, 'rimraf: missing options')
|
||||
assert.equal(typeof options, 'object', 'rimraf: options should be object')
|
||||
|
||||
var results
|
||||
|
||||
if (options.disableGlob || !glob.hasMagic(p)) {
|
||||
results = [p]
|
||||
} else {
|
||||
try {
|
||||
options.lstatSync(p)
|
||||
results = [p]
|
||||
} catch (er) {
|
||||
results = glob.sync(p, options.glob)
|
||||
}
|
||||
}
|
||||
|
||||
if (!results.length)
|
||||
return
|
||||
|
||||
for (var i = 0; i < results.length; i++) {
|
||||
var p = results[i]
|
||||
|
||||
try {
|
||||
var st = options.lstatSync(p)
|
||||
} catch (er) {
|
||||
if (er.code === "ENOENT")
|
||||
return
|
||||
|
||||
// Windows can EPERM on stat. Life is suffering.
|
||||
if (er.code === "EPERM" && isWindows)
|
||||
fixWinEPERMSync(p, options, er)
|
||||
}
|
||||
|
||||
try {
|
||||
// sunos lets the root user unlink directories, which is... weird.
|
||||
if (st && st.isDirectory())
|
||||
rmdirSync(p, options, null)
|
||||
else
|
||||
options.unlinkSync(p)
|
||||
} catch (er) {
|
||||
if (er.code === "ENOENT")
|
||||
return
|
||||
if (er.code === "EPERM")
|
||||
return isWindows ? fixWinEPERMSync(p, options, er) : rmdirSync(p, options, er)
|
||||
if (er.code !== "EISDIR")
|
||||
throw er
|
||||
|
||||
rmdirSync(p, options, er)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
function rmdirSync (p, options, originalEr) {
|
||||
assert(p)
|
||||
assert(options)
|
||||
if (originalEr)
|
||||
assert(originalEr instanceof Error)
|
||||
|
||||
try {
|
||||
options.rmdirSync(p)
|
||||
} catch (er) {
|
||||
if (er.code === "ENOENT")
|
||||
return
|
||||
if (er.code === "ENOTDIR")
|
||||
throw originalEr
|
||||
if (er.code === "ENOTEMPTY" || er.code === "EEXIST" || er.code === "EPERM")
|
||||
rmkidsSync(p, options)
|
||||
}
|
||||
}
|
||||
|
||||
function rmkidsSync (p, options) {
|
||||
assert(p)
|
||||
assert(options)
|
||||
options.readdirSync(p).forEach(function (f) {
|
||||
rimrafSync(path.join(p, f), options)
|
||||
})
|
||||
|
||||
// We only end up here once we got ENOTEMPTY at least once, and
|
||||
// at this point, we are guaranteed to have removed all the kids.
|
||||
// So, we know that it won't be ENOENT or ENOTDIR or anything else.
|
||||
// try really hard to delete stuff on windows, because it has a
|
||||
// PROFOUNDLY annoying habit of not closing handles promptly when
|
||||
// files are deleted, resulting in spurious ENOTEMPTY errors.
|
||||
var retries = isWindows ? 100 : 1
|
||||
var i = 0
|
||||
do {
|
||||
var threw = true
|
||||
try {
|
||||
var ret = options.rmdirSync(p, options)
|
||||
threw = false
|
||||
return ret
|
||||
} finally {
|
||||
if (++i < retries && threw)
|
||||
continue
|
||||
}
|
||||
} while (true)
|
||||
}
|
||||
43
node_modules/tmp/package.json
generated
vendored
Normal file
43
node_modules/tmp/package.json
generated
vendored
Normal file
|
|
@ -0,0 +1,43 @@
|
|||
{
|
||||
"name": "tmp",
|
||||
"version": "0.1.0",
|
||||
"description": "Temporary file and directory creator",
|
||||
"author": "KARASZI István <github@spam.raszi.hu> (http://raszi.hu/)",
|
||||
"keywords": [
|
||||
"temporary",
|
||||
"tmp",
|
||||
"temp",
|
||||
"tempdir",
|
||||
"tempfile",
|
||||
"tmpdir",
|
||||
"tmpfile"
|
||||
],
|
||||
"license": "MIT",
|
||||
"repository": "raszi/node-tmp",
|
||||
"homepage": "http://github.com/raszi/node-tmp",
|
||||
"bugs": {
|
||||
"url": "http://github.com/raszi/node-tmp/issues"
|
||||
},
|
||||
"engines": {
|
||||
"node": ">=6"
|
||||
},
|
||||
"dependencies": {
|
||||
"rimraf": "^2.6.3"
|
||||
},
|
||||
"devDependencies": {
|
||||
"eslint": "^4.19.1",
|
||||
"eslint-plugin-mocha": "^5.0.0",
|
||||
"istanbul": "^0.4.5",
|
||||
"mocha": "^5.1.1"
|
||||
},
|
||||
"main": "lib/tmp.js",
|
||||
"files": [
|
||||
"lib/"
|
||||
],
|
||||
"scripts": {
|
||||
"lint": "eslint lib --env mocha test",
|
||||
"clean": "rm -Rf ./coverage",
|
||||
"test": "npm run clean && istanbul cover ./node_modules/mocha/bin/_mocha --report none --print none --dir ./coverage/json -u exports -R test/*-test.js && istanbul report --root ./coverage/json html && istanbul report text-summary",
|
||||
"doc": "jsdoc -c .jsdoc.json"
|
||||
}
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue