try saving bash script as file

This commit is contained in:
ibrahim0814
2019-11-18 23:39:04 -08:00
parent 889584d6f9
commit 1be0517b99
93 changed files with 10599 additions and 17 deletions

20
node_modules/temp/LICENSE generated vendored Normal file
View File

@@ -0,0 +1,20 @@
The MIT License (MIT)
Copyright (c) 2010-2014 Bruce Williams
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.

295
node_modules/temp/README.md generated vendored Normal file
View File

@@ -0,0 +1,295 @@
node-temp
=========
Temporary files, directories, and streams for Node.js.
Handles generating a unique file/directory name under the appropriate
system temporary directory, changing the file to an appropriate mode,
and supports automatic removal (if asked)
`temp` has a similar API to the `fs` module.
Node.js Compatibility
---------------------
Supports v4.0.0+.
[![Build Status](https://travis-ci.org/bruce/node-temp.png)](https://travis-ci.org/bruce/node-temp)
Please let me know if you have problems running it on a later version of Node.js or
have platform-specific problems.
Installation
------------
Install it using [npm](http://github.com/isaacs/npm):
$ npm install temp
Or get it directly from:
http://github.com/bruce/node-temp
Synopsis
--------
You can create temporary files with `open` and `openSync`, temporary
directories with `mkdir` and `mkdirSync`, or you can get a unique name
in the system temporary directory with `path`.
Working copies of the following examples can be found under the
`examples` directory.
### Temporary Files
To create a temporary file use `open` or `openSync`, passing
them an optional prefix, suffix, or both (see below for details on
affixes). The object passed to the callback (or returned) has
`path` and `fd` keys:
```javascript
{ path: "/path/to/file",
, fd: theFileDescriptor
}
```
In this example we write to a temporary file and call out to `grep` and
`wc -l` to determine the number of time `foo` occurs in the text. The
temporary file is chmod'd `0600` and cleaned up automatically when the
process at exit (because `temp.track()` is called):
```javascript
var temp = require('temp'),
fs = require('fs'),
util = require('util'),
exec = require('child_process').exec;
// Automatically track and cleanup files at exit
temp.track();
// Fake data
var myData = "foo\nbar\nfoo\nbaz";
// Process the data (note: error handling omitted)
temp.open('myprefix', function(err, info) {
if (!err) {
fs.write(info.fd, myData);
fs.close(info.fd, function(err) {
exec("grep foo '" + info.path + "' | wc -l", function(err, stdout) {
util.puts(stdout.trim());
});
});
}
});
```
### Want Cleanup? Make sure you ask for it.
As noted in the example above, if you want temp to track the files and
directories it creates and handle removing those files and directories
on exit, you must call `track()`. The `track()` function is chainable,
and it's recommended that you call it when requiring the module.
```javascript
var temp = require("temp").track();
```
Why is this necessary? In pre-0.6 versions of temp, tracking was
automatic. While this works great for scripts and
[Grunt tasks](http://gruntjs.com/), it's not so great for long-running
server processes. Since that's arguably what Node.js is _for_, you
have to opt-in to tracking.
But it's easy.
#### Cleanup anytime
When tracking, you can run `cleanup()` and `cleanupSync()` anytime
(`cleanupSync()` will be run for you on process exit). An object will
be returned (or passed to the callback) with cleanup counts and
the file/directory tracking lists will be reset.
```javascript
> temp.cleanupSync();
{ files: 1,
dirs: 0 }
```
```javascript
> temp.cleanup(function(err, stats) {
console.log(stats);
});
{ files: 1,
dirs: 0 }
```
Note: If you're not tracking, an error ("not tracking") will be passed
to the callback.
### Temporary Directories
To create a temporary directory, use `mkdir` or `mkdirSync`, passing
it an optional prefix, suffix, or both (see below for details on affixes).
In this example we create a temporary directory, write to a file
within it, call out to an external program to create a PDF, and read
the result. While the external process creates a lot of additional
files, the temporary directory is removed automatically at exit (because
`temp.track()` is called):
```javascript
var temp = require('temp'),
fs = require('fs'),
util = require('util'),
path = require('path'),
exec = require('child_process').exec;
// Automatically track and cleanup files at exit
temp.track();
// For use with ConTeXt, http://wiki.contextgarden.net
var myData = "\\starttext\nHello World\n\\stoptext";
temp.mkdir('pdfcreator', function(err, dirPath) {
var inputPath = path.join(dirPath, 'input.tex')
fs.writeFile(inputPath, myData, function(err) {
if (err) throw err;
process.chdir(dirPath);
exec("texexec '" + inputPath + "'", function(err) {
if (err) throw err;
fs.readFile(path.join(dirPath, 'input.pdf'), function(err, data) {
if (err) throw err;
sys.print(data);
});
});
});
});
```
### Temporary Streams
To create a temporary WriteStream, use 'createWriteStream', which sits
on top of `fs.createWriteStream`. The return value is a
`fs.WriteStream` with a `path` property containing the temporary file
path for the stream. The `path` is registered for removal when
`temp.cleanup` is called (because `temp.track()` is called).
```javascript
var temp = require('temp');
// Automatically track and cleanup files at exit
temp.track();
var stream = temp.createWriteStream();
// stream.path contains the temporary file path for the stream
stream.write("Some data");
// Maybe do some other things
stream.end();
```
### Affixes
You can provide custom prefixes and suffixes when creating temporary
files and directories. If you provide a string, it is used as the prefix
for the temporary name. If you provide an object with `prefix`,
`suffix` and `dir` keys, they are used for the temporary name.
Here are some examples:
* `"aprefix"`: A simple prefix, prepended to the filename; this is
shorthand for:
* `{prefix: "aprefix"}`: A simple prefix, prepended to the filename
* `{suffix: ".asuffix"}`: A suffix, appended to the filename
(especially useful when the file needs to be named with specific
extension for use with an external program).
* `{prefix: "myprefix", suffix: "mysuffix"}`: Customize both affixes
* `{dir: path.join(os.tmpdir(), "myapp")}`: default prefix and suffix
within a new temporary directory.
* `null`: Use the defaults for files and directories (prefixes `"f-"`
and `"d-"`, respectively, no suffixes).
In this simple example we read a `pdf`, write it to a temporary file with
a `.pdf` extension, and close it.
```javascript
var fs = require('fs'),
temp = require('temp');
fs.readFile('/path/to/source.pdf', function(err, data) {
temp.open({suffix: '.pdf'}, function(err, info) {
if (err) throw err;
fs.write(info.fd, data);
fs.close(info.fd, function(err) {
if (err) throw err;
// Do something with the file
});
});
});
```
### Just a path, please
If you just want a unique name in your temporary directory, use
`path`:
```javascript
var fs = require('fs');
var tempName = temp.path({suffix: '.pdf'});
// Do something with tempName
```
Note: The file isn't created for you, and the mode is not changed -- and it
will not be removed automatically at exit. If you use `path`, it's
all up to you.
Using it with Grunt
-------------------
If you want to use the module with [Grunt](http://gruntjs.com/), make sure you
use `async()` in your Gruntfile:
```javascript
module.exports = function (grunt) {
var temp = require("temp");
temp.track(); // Cleanup files, please
grunt.registerTask("temptest", "Testing temp", function() {
var done = this.async(); // Don't forget this!
grunt.log.writeln("About to write a file...");
temp.open('tempfile', function(err, info) {
// File writing shenanigans here
grunt.log.writeln("Wrote a file!")
done(); // REALLY don't forget this!
});
});
};
```
For more information, see the [Grunt FAQ](http://gruntjs.com/frequently-asked-questions#why-doesn-t-my-asynchronous-task-complete).
Testing
-------
```sh
$ npm test
```
Contributing
------------
You can find the repository at:
http://github.com/bruce/node-temp
Issues/Feature Requests can be submitted at:
http://github.com/bruce/node-temp/issues
I'd really like to hear your feedback, and I'd love to receive your
pull-requests!
Copyright
---------
Copyright (c) 2010-2014 Bruce Williams. This software is licensed
under the MIT License, see LICENSE for details.

314
node_modules/temp/lib/temp.js generated vendored Normal file
View File

@@ -0,0 +1,314 @@
var fs = require('fs'),
path = require('path'),
cnst = require('constants');
var rimraf = require('rimraf'),
os = require('os'),
rimrafSync = rimraf.sync;
/* HELPERS */
var dir = path.resolve(os.tmpdir());
var RDWR_EXCL = cnst.O_CREAT | cnst.O_TRUNC | cnst.O_RDWR | cnst.O_EXCL;
var promisify = function(callback) {
if (typeof callback === 'function') {
return [undefined, callback];
}
var promiseCallback;
var promise = new Promise(function(resolve, reject) {
promiseCallback = function() {
var args = Array.from(arguments);
var err = args.shift();
process.nextTick(function() {
if (err) {
reject(err);
} else if (args.length === 1) {
resolve(args[0]);
} else {
resolve(args);
}
});
};
});
return [promise, promiseCallback];
};
var generateName = function(rawAffixes, defaultPrefix) {
var affixes = parseAffixes(rawAffixes, defaultPrefix);
var now = new Date();
var name = [affixes.prefix,
now.getFullYear(), now.getMonth(), now.getDate(),
'-',
process.pid,
'-',
(Math.random() * 0x100000000 + 1).toString(36),
affixes.suffix].join('');
return path.join(affixes.dir || dir, name);
};
var parseAffixes = function(rawAffixes, defaultPrefix) {
var affixes = {prefix: null, suffix: null};
if(rawAffixes) {
switch (typeof(rawAffixes)) {
case 'string':
affixes.prefix = rawAffixes;
break;
case 'object':
affixes = rawAffixes;
break;
default:
throw new Error("Unknown affix declaration: " + affixes);
}
} else {
affixes.prefix = defaultPrefix;
}
return affixes;
};
/* -------------------------------------------------------------------------
* Don't forget to call track() if you want file tracking and exit handlers!
* -------------------------------------------------------------------------
* When any temp file or directory is created, it is added to filesToDelete
* or dirsToDelete. The first time any temp file is created, a listener is
* added to remove all temp files and directories at exit.
*/
var tracking = false;
var track = function(value) {
tracking = (value !== false);
return module.exports; // chainable
};
var exitListenerAttached = false;
var filesToDelete = [];
var dirsToDelete = [];
function deleteFileOnExit(filePath) {
if (!tracking) return false;
attachExitListener();
filesToDelete.push(filePath);
}
function deleteDirOnExit(dirPath) {
if (!tracking) return false;
attachExitListener();
dirsToDelete.push(dirPath);
}
function attachExitListener() {
if (!tracking) return false;
if (!exitListenerAttached) {
process.addListener('exit', cleanupSync);
exitListenerAttached = true;
}
}
function cleanupFilesSync() {
if (!tracking) {
return false;
}
var count = 0;
var toDelete;
while ((toDelete = filesToDelete.shift()) !== undefined) {
rimrafSync(toDelete);
count++;
}
return count;
}
function cleanupFiles(callback) {
var p = promisify(callback);
var promise = p[0];
callback = p[1];
if (!tracking) {
callback(new Error("not tracking"));
return promise;
}
var count = 0;
var left = filesToDelete.length;
if (!left) {
callback(null, count);
return promise;
}
var toDelete;
var rimrafCallback = function(err) {
if (!left) {
// Prevent processing if aborted
return;
}
if (err) {
// This shouldn't happen; pass error to callback and abort
// processing
callback(err);
left = 0;
return;
} else {
count++;
}
left--;
if (!left) {
callback(null, count);
}
};
while ((toDelete = filesToDelete.shift()) !== undefined) {
rimraf(toDelete, rimrafCallback);
}
return promise;
}
function cleanupDirsSync() {
if (!tracking) {
return false;
}
var count = 0;
var toDelete;
while ((toDelete = dirsToDelete.shift()) !== undefined) {
rimrafSync(toDelete);
count++;
}
return count;
}
function cleanupDirs(callback) {
var p = promisify(callback);
var promise = p[0];
callback = p[1];
if (!tracking) {
callback(new Error("not tracking"));
return promise;
}
var count = 0;
var left = dirsToDelete.length;
if (!left) {
callback(null, count);
return promise;
}
var toDelete;
var rimrafCallback = function (err) {
if (!left) {
// Prevent processing if aborted
return;
}
if (err) {
// rimraf handles most "normal" errors; pass the error to the
// callback and abort processing
callback(err, count);
left = 0;
return;
} else {
count++;
}
left--;
if (!left) {
callback(null, count);
}
};
while ((toDelete = dirsToDelete.shift()) !== undefined) {
rimraf(toDelete, rimrafCallback);
}
return promise;
}
function cleanupSync() {
if (!tracking) {
return false;
}
var fileCount = cleanupFilesSync();
var dirCount = cleanupDirsSync();
return {files: fileCount, dirs: dirCount};
}
function cleanup(callback) {
var p = promisify(callback);
var promise = p[0];
callback = p[1];
if (!tracking) {
callback(new Error("not tracking"));
return promise;
}
cleanupFiles(function(fileErr, fileCount) {
if (fileErr) {
callback(fileErr, {files: fileCount});
} else {
cleanupDirs(function(dirErr, dirCount) {
callback(dirErr, {files: fileCount, dirs: dirCount});
});
}
});
return promise;
}
/* DIRECTORIES */
function mkdir(affixes, callback) {
var p = promisify(callback);
var promise = p[0];
callback = p[1];
var dirPath = generateName(affixes, 'd-');
fs.mkdir(dirPath, parseInt('0700', 8), function(err) {
if (!err) {
deleteDirOnExit(dirPath);
}
callback(err, dirPath);
});
return promise;
}
function mkdirSync(affixes) {
var dirPath = generateName(affixes, 'd-');
fs.mkdirSync(dirPath, parseInt('0700', 8));
deleteDirOnExit(dirPath);
return dirPath;
}
/* FILES */
function open(affixes, callback) {
var p = promisify(callback);
var promise = p[0];
callback = p[1];
var filePath = generateName(affixes, 'f-');
fs.open(filePath, RDWR_EXCL, parseInt('0600', 8), function(err, fd) {
if (!err) {
deleteFileOnExit(filePath);
}
callback(err, {path: filePath, fd: fd});
});
return promise;
}
function openSync(affixes) {
var filePath = generateName(affixes, 'f-');
var fd = fs.openSync(filePath, RDWR_EXCL, parseInt('0600', 8));
deleteFileOnExit(filePath);
return {path: filePath, fd: fd};
}
function createWriteStream(affixes) {
var filePath = generateName(affixes, 's-');
var stream = fs.createWriteStream(filePath, {flags: RDWR_EXCL, mode: parseInt('0600', 8)});
deleteFileOnExit(filePath);
return stream;
}
/* EXPORTS */
// Settings
exports.dir = dir;
exports.track = track;
// Functions
exports.mkdir = mkdir;
exports.mkdirSync = mkdirSync;
exports.open = open;
exports.openSync = openSync;
exports.path = generateName;
exports.cleanup = cleanup;
exports.cleanupSync = cleanupSync;
exports.createWriteStream = createWriteStream;

1
node_modules/temp/node_modules/.bin/rimraf generated vendored Symbolic link
View File

@@ -0,0 +1 @@
../rimraf/bin.js

15
node_modules/temp/node_modules/rimraf/LICENSE generated vendored Normal file
View 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/temp/node_modules/rimraf/README.md generated vendored Normal file
View File

@@ -0,0 +1,101 @@
[![Build Status](https://travis-ci.org/isaacs/rimraf.svg?branch=master)](https://travis-ci.org/isaacs/rimraf) [![Dependency Status](https://david-dm.org/isaacs/rimraf.svg)](https://david-dm.org/isaacs/rimraf) [![devDependency Status](https://david-dm.org/isaacs/rimraf/dev-status.svg)](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/temp/node_modules/rimraf/bin.js generated vendored Executable file
View 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)
})
}

67
node_modules/temp/node_modules/rimraf/package.json generated vendored Normal file
View File

@@ -0,0 +1,67 @@
{
"_from": "rimraf@~2.6.2",
"_id": "rimraf@2.6.3",
"_inBundle": false,
"_integrity": "sha512-mwqeW5XsA2qAejG46gYdENaxXjx9onRNCfn7L0duuP4hCuTIi/QO7PDK07KJfp1d+izWPrzEJDcSqBa0OZQriA==",
"_location": "/temp/rimraf",
"_phantomChildren": {},
"_requested": {
"type": "range",
"registry": true,
"raw": "rimraf@~2.6.2",
"name": "rimraf",
"escapedName": "rimraf",
"rawSpec": "~2.6.2",
"saveSpec": null,
"fetchSpec": "~2.6.2"
},
"_requiredBy": [
"/temp"
],
"_resolved": "https://registry.npmjs.org/rimraf/-/rimraf-2.6.3.tgz",
"_shasum": "b2d104fe0d8fb27cf9e0a1cda8262dd3833c6cab",
"_spec": "rimraf@~2.6.2",
"_where": "/Users/Ibrahim/Desktop/test2/node_modules/temp",
"author": {
"name": "Isaac Z. Schlueter",
"email": "i@izs.me",
"url": "http://blog.izs.me/"
},
"bin": {
"rimraf": "./bin.js"
},
"bugs": {
"url": "https://github.com/isaacs/rimraf/issues"
},
"bundleDependencies": false,
"dependencies": {
"glob": "^7.1.3"
},
"deprecated": false,
"description": "A deep deletion module for node (like `rm -rf`)",
"devDependencies": {
"mkdirp": "^0.5.1",
"tap": "^12.1.1"
},
"files": [
"LICENSE",
"README.md",
"bin.js",
"rimraf.js"
],
"homepage": "https://github.com/isaacs/rimraf#readme",
"license": "ISC",
"main": "rimraf.js",
"name": "rimraf",
"repository": {
"type": "git",
"url": "git://github.com/isaacs/rimraf.git"
},
"scripts": {
"postpublish": "git push origin --all; git push origin --tags",
"postversion": "npm publish",
"preversion": "npm test",
"test": "tap test/*.js"
},
"version": "2.6.3"
}

364
node_modules/temp/node_modules/rimraf/rimraf.js generated vendored Normal file
View File

@@ -0,0 +1,364 @@
module.exports = rimraf
rimraf.sync = rimrafSync
var assert = require("assert")
var path = require("path")
var fs = require("fs")
var glob = require("glob")
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
}
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)
}

83
node_modules/temp/package.json generated vendored Normal file
View File

@@ -0,0 +1,83 @@
{
"_from": "temp",
"_id": "temp@0.9.1",
"_inBundle": false,
"_integrity": "sha512-WMuOgiua1xb5R56lE0eH6ivpVmg/lq2OHm4+LtT/xtEtPQ+sz6N3bBM6WZ5FvO1lO4IKIOb43qnhoc4qxP5OeA==",
"_location": "/temp",
"_phantomChildren": {
"glob": "7.1.6"
},
"_requested": {
"type": "tag",
"registry": true,
"raw": "temp",
"name": "temp",
"escapedName": "temp",
"rawSpec": "",
"saveSpec": null,
"fetchSpec": "latest"
},
"_requiredBy": [
"#USER",
"/"
],
"_resolved": "https://registry.npmjs.org/temp/-/temp-0.9.1.tgz",
"_shasum": "2d666114fafa26966cd4065996d7ceedd4dd4697",
"_spec": "temp",
"_where": "/Users/Ibrahim/Desktop/test2",
"author": {
"name": "Bruce Williams",
"email": "brwcodes@gmail.com"
},
"bugs": {
"url": "https://github.com/bruce/node-temp/issues"
},
"bundleDependencies": false,
"dependencies": {
"rimraf": "~2.6.2"
},
"deprecated": false,
"description": "Temporary files and directories",
"devDependencies": {
"mocha": "6.2.2"
},
"directories": {
"lib": "lib"
},
"engines": {
"node": ">=6.0.0"
},
"files": [
"lib"
],
"homepage": "https://github.com/bruce/node-temp#readme",
"keywords": [
"temporary",
"tmp",
"temp",
"tempdir",
"tempfile",
"tmpdir",
"tmpfile"
],
"license": "MIT",
"main": "./lib/temp",
"name": "temp",
"repository": {
"type": "git",
"url": "git://github.com/bruce/node-temp.git"
},
"scripts": {
"test": "mocha test/temp-test.js"
},
"tags": [
"temporary",
"temp",
"tempfile",
"tempdir",
"tmpfile",
"tmpdir",
"security"
],
"version": "0.9.1"
}