initial commit taken from gitlab.lrz.de

This commit is contained in:
privatereese
2018-08-24 18:09:42 +02:00
parent ae54ed4c48
commit fc05486403
28494 changed files with 2159823 additions and 0 deletions

7
node_modules/temp/.npmignore generated vendored Normal file
View File

@@ -0,0 +1,7 @@
.DS_Store
.\#*
/node_modules
\#*
npm-debug.log
node_modules
*.tgz

4
node_modules/temp/.travis.yml generated vendored Normal file
View File

@@ -0,0 +1,4 @@
language: node_js
node_js:
- "0.11"
- "0.10"

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.

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

@@ -0,0 +1,293 @@
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 v0.10.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` whose `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.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, contents);
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.

18
node_modules/temp/examples/grepcount.js generated vendored Normal file
View File

@@ -0,0 +1,18 @@
var temp = require('../lib/temp'),
fs = require('fs'),
util = require('util'),
exec = require('child_process').exec;
var myData = "foo\nbar\nfoo\nbaz";
temp.open('myprefix', function(err, info) {
if (err) throw err;
fs.write(info.fd, myData);
fs.close(info.fd, function(err) {
if (err) throw err;
exec("grep foo '" + info.path + "' | wc -l", function(err, stdout) {
if (err) throw err;
util.puts(stdout.trim());
});
});
});

22
node_modules/temp/examples/pdfcreator.js generated vendored Normal file
View File

@@ -0,0 +1,22 @@
var temp = require('../lib/temp'),
fs = require('fs'),
util = require('util'),
path = require('path'),
exec = require('child_process').exec;
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;
util.print(data);
});
});
});
});

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

@@ -0,0 +1,283 @@
var fs = require('fs'),
path = require('path'),
cnst = require('constants');
var rimraf = require('rimraf'),
osTmpdir = require('os-tmpdir'),
rimrafSync = rimraf.sync;
/* HELPERS */
var RDWR_EXCL = cnst.O_CREAT | cnst.O_TRUNC | cnst.O_RDWR | cnst.O_EXCL;
var generateName = function(rawAffixes, defaultPrefix) {
var affixes = parseAffixes(rawAffixes, defaultPrefix);
var now = new Date();
var name = [affixes.prefix,
now.getYear(), now.getMonth(), now.getDate(),
'-',
process.pid,
'-',
(Math.random() * 0x100000000 + 1).toString(36),
affixes.suffix].join('');
return path.join(affixes.dir || exports.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) {
if (!tracking) {
if (callback) {
callback(new Error("not tracking"));
}
return;
}
var count = 0;
var left = filesToDelete.length;
if (!left) {
if (callback) {
callback(null, count);
}
return;
}
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
if (callback) {
callback(err);
}
left = 0;
return;
} else {
count++;
}
left--;
if (!left && callback) {
callback(null, count);
}
};
while ((toDelete = filesToDelete.shift()) !== undefined) {
rimraf(toDelete, rimrafCallback);
}
}
function cleanupDirsSync() {
if (!tracking) {
return false;
}
var count = 0;
var toDelete;
while ((toDelete = dirsToDelete.shift()) !== undefined) {
rimrafSync(toDelete);
count++;
}
return count;
}
function cleanupDirs(callback) {
if (!tracking) {
if (callback) {
callback(new Error("not tracking"));
}
return;
}
var count = 0;
var left = dirsToDelete.length;
if (!left) {
if (callback) {
callback(null, count);
}
return;
}
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
if (callback) {
callback(err, count);
}
left = 0;
return;
} else {
count;
}
left--;
if (!left && callback) {
callback(null, count);
}
};
while ((toDelete = dirsToDelete.shift()) !== undefined) {
rimraf(toDelete, rimrafCallback);
}
}
function cleanupSync() {
if (!tracking) {
return false;
}
var fileCount = cleanupFilesSync();
var dirCount = cleanupDirsSync();
return {files: fileCount, dirs: dirCount};
}
function cleanup(callback) {
if (!tracking) {
if (callback) {
callback(new Error("not tracking"));
}
return;
}
cleanupFiles(function(fileErr, fileCount) {
if (fileErr) {
if (callback) {
callback(fileErr, {files: fileCount})
}
} else {
cleanupDirs(function(dirErr, dirCount) {
if (callback) {
callback(dirErr, {files: fileCount, dirs: dirCount});
}
});
}
});
}
/* DIRECTORIES */
function mkdir(affixes, callback) {
var dirPath = generateName(affixes, 'd-');
fs.mkdir(dirPath, 0700, function(err) {
if (!err) {
deleteDirOnExit(dirPath);
}
if (callback) {
callback(err, dirPath);
}
});
}
function mkdirSync(affixes) {
var dirPath = generateName(affixes, 'd-');
fs.mkdirSync(dirPath, 0700);
deleteDirOnExit(dirPath);
return dirPath;
}
/* FILES */
function open(affixes, callback) {
var filePath = generateName(affixes, 'f-');
fs.open(filePath, RDWR_EXCL, 0600, function(err, fd) {
if (!err) {
deleteFileOnExit(filePath);
}
if (callback) {
callback(err, {path: filePath, fd: fd});
}
});
}
function openSync(affixes) {
var filePath = generateName(affixes, 'f-');
var fd = fs.openSync(filePath, RDWR_EXCL, 0600);
deleteFileOnExit(filePath);
return {path: filePath, fd: fd};
}
function createWriteStream(affixes) {
var filePath = generateName(affixes, 's-');
var stream = fs.createWriteStream(filePath, {flags: RDWR_EXCL, mode: 0600});
deleteFileOnExit(filePath);
return stream;
}
/* EXPORTS */
// Settings
exports.dir = path.resolve(osTmpdir());
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;

4
node_modules/temp/no_cleanup.js generated vendored Normal file
View File

@@ -0,0 +1,4 @@
var temp = require('temp').track();
var p = temp.mkdirSync("shouldBeDeletedOnExitNotJasmine");
console.log('created dir ' + p);

8
node_modules/temp/no_cleanup_on_exit.js generated vendored Normal file
View File

@@ -0,0 +1,8 @@
var temp = require('temp').track();
describe('temp will create dir that will remain after the process exits', function() {
it('creates a dir', function() {
var p = temp.mkdirSync("shouldBeDeletedOnExit");
console.log('created dir ' + p);
});
});

11
node_modules/temp/no_cleanup_on_exit.spec.js generated vendored Normal file
View File

@@ -0,0 +1,11 @@
var temp = require('temp');
temp.track();
console.log('Doing something');
describe('temp will create dir that will remain after the process exits', function() {
it('creates a dir', function() {
var p = temp.mkdirSync("shouldBeDeletedOnExit");
console.log('created dir ' + p);
});
});

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

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

6
node_modules/temp/node_modules/rimraf/AUTHORS generated vendored Normal file
View File

@@ -0,0 +1,6 @@
# Authors sorted by whether or not they're me.
Isaac Z. Schlueter <i@izs.me> (http://blog.izs.me)
Wayne Larsen <wayne@larsen.st> (http://github.com/wvl)
ritch <skawful@gmail.com>
Marcel Laverdet
Yosef Dinerstein <yosefd@microsoft.com>

23
node_modules/temp/node_modules/rimraf/LICENSE generated vendored Normal file
View File

@@ -0,0 +1,23 @@
Copyright 2009, 2010, 2011 Isaac Z. Schlueter.
All rights reserved.
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.

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

@@ -0,0 +1,30 @@
`rm -rf` for node.
Install with `npm install rimraf`, or just drop rimraf.js somewhere.
## API
`rimraf(f, callback)`
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.
* `ENOENT` - If the file doesn't exist, rimraf will return
successfully, since your desired outcome is already the case.
## 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>` 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).

33
node_modules/temp/node_modules/rimraf/bin.js generated vendored Executable file
View File

@@ -0,0 +1,33 @@
#!/usr/bin/env node
var rimraf = require('./')
var help = false
var dashdash = false
var args = process.argv.slice(2).filter(function(arg) {
if (dashdash)
return !!arg
else if (arg === '--')
dashdash = true
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>')
log('')
log(' Deletes all files and folders at "path" recursively.')
log('')
log('Options:')
log('')
log(' -h, --help Display this usage info')
process.exit(help ? 0 : 1)
} else {
args.forEach(function(arg) {
rimraf.sync(arg)
})
}

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

@@ -0,0 +1,100 @@
{
"_args": [
[
"rimraf@~2.2.6",
"/home/bernhard/freifunk-app/node_modules/temp"
]
],
"_from": "rimraf@>=2.2.6 <2.3.0",
"_id": "rimraf@2.2.8",
"_inCache": true,
"_installable": true,
"_location": "/temp/rimraf",
"_npmUser": {
"email": "i@izs.me",
"name": "isaacs"
},
"_npmVersion": "1.4.10",
"_phantomChildren": {},
"_requested": {
"name": "rimraf",
"raw": "rimraf@~2.2.6",
"rawSpec": "~2.2.6",
"scope": null,
"spec": ">=2.2.6 <2.3.0",
"type": "range"
},
"_requiredBy": [
"/temp"
],
"_resolved": "https://registry.npmjs.org/rimraf/-/rimraf-2.2.8.tgz",
"_shasum": "e439be2aaee327321952730f99a8929e4fc50582",
"_shrinkwrap": null,
"_spec": "rimraf@~2.2.6",
"_where": "/home/bernhard/freifunk-app/node_modules/temp",
"author": {
"email": "i@izs.me",
"name": "Isaac Z. Schlueter",
"url": "http://blog.izs.me/"
},
"bin": {
"rimraf": "./bin.js"
},
"bugs": {
"url": "https://github.com/isaacs/rimraf/issues"
},
"contributors": [
{
"name": "Isaac Z. Schlueter",
"email": "i@izs.me",
"url": "http://blog.izs.me"
},
{
"name": "Wayne Larsen",
"email": "wayne@larsen.st",
"url": "http://github.com/wvl"
},
{
"name": "ritch",
"email": "skawful@gmail.com"
},
{
"name": "Marcel Laverdet"
},
{
"name": "Yosef Dinerstein",
"email": "yosefd@microsoft.com"
}
],
"dependencies": {},
"description": "A deep deletion module for node (like `rm -rf`)",
"devDependencies": {},
"directories": {},
"dist": {
"shasum": "e439be2aaee327321952730f99a8929e4fc50582",
"tarball": "https://registry.npmjs.org/rimraf/-/rimraf-2.2.8.tgz"
},
"homepage": "https://github.com/isaacs/rimraf",
"license": {
"type": "MIT",
"url": "https://github.com/isaacs/rimraf/raw/master/LICENSE"
},
"main": "rimraf.js",
"maintainers": [
{
"name": "isaacs",
"email": "i@izs.me"
}
],
"name": "rimraf",
"optionalDependencies": {},
"readme": "ERROR: No README data found!",
"repository": {
"type": "git",
"url": "git://github.com/isaacs/rimraf.git"
},
"scripts": {
"test": "cd test && bash run.sh"
},
"version": "2.2.8"
}

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

@@ -0,0 +1,248 @@
module.exports = rimraf
rimraf.sync = rimrafSync
var assert = require("assert")
var path = require("path")
var fs = require("fs")
// for EMFILE handling
var timeout = 0
exports.EMFILE_MAX = 1000
exports.BUSYTRIES_MAX = 3
var isWindows = (process.platform === "win32")
function defaults (options) {
var methods = [
'unlink',
'chmod',
'stat',
'rmdir',
'readdir'
]
methods.forEach(function(m) {
options[m] = options[m] || fs[m]
m = m + 'Sync'
options[m] = options[m] || fs[m]
})
}
function rimraf (p, options, cb) {
if (typeof options === 'function') {
cb = options
options = {}
}
assert(p)
assert(options)
assert(typeof cb === 'function')
defaults(options)
if (!cb) throw new Error("No callback passed to rimraf()")
var busyTries = 0
rimraf_(p, options, function CB (er) {
if (er) {
if (isWindows && (er.code === "EBUSY" || er.code === "ENOTEMPTY") &&
busyTries < exports.BUSYTRIES_MAX) {
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 < exports.EMFILE_MAX) {
return setTimeout(function () {
rimraf_(p, options, CB)
}, timeout ++)
}
// already gone
if (er.code === "ENOENT") er = null
}
timeout = 0
cb(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')
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, 666, 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, 666)
} 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)
assert(options)
try {
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)
})
options.rmdirSync(p, options)
}

16
node_modules/temp/node_modules/rimraf/test/run.sh generated vendored Normal file
View File

@@ -0,0 +1,16 @@
#!/bin/bash
set -e
code=0
for i in test-*.js; do
echo -n $i ...
bash setup.sh
node $i
if [ -d target ]; then
echo "fail"
code=1
else
echo "pass"
fi
done
rm -rf target
exit $code

47
node_modules/temp/node_modules/rimraf/test/setup.sh generated vendored Normal file
View File

@@ -0,0 +1,47 @@
#!/bin/bash
set -e
files=10
folders=2
depth=4
target="$PWD/target"
rm -rf target
fill () {
local depth=$1
local files=$2
local folders=$3
local target=$4
if ! [ -d $target ]; then
mkdir -p $target
fi
local f
f=$files
while [ $f -gt 0 ]; do
touch "$target/f-$depth-$f"
let f--
done
let depth--
if [ $depth -le 0 ]; then
return 0
fi
f=$folders
while [ $f -gt 0 ]; do
mkdir "$target/folder-$depth-$f"
fill $depth $files $folders "$target/d-$depth-$f"
let f--
done
}
fill $depth $files $folders $target
# sanity assert
[ -d $target ]

View File

@@ -0,0 +1,5 @@
var rimraf = require("../rimraf")
, path = require("path")
rimraf(path.join(__dirname, "target"), function (er) {
if (er) throw er
})

View File

@@ -0,0 +1,3 @@
var rimraf = require("../rimraf")
, path = require("path")
rimraf.sync(path.join(__dirname, "target"))

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

@@ -0,0 +1,98 @@
{
"_args": [
[
"temp@0.8.3",
"/home/bernhard/freifunk-app/node_modules/metro"
]
],
"_from": "temp@0.8.3",
"_id": "temp@0.8.3",
"_inCache": true,
"_installable": true,
"_location": "/temp",
"_nodeVersion": "0.12.0",
"_npmUser": {
"email": "brwcodes@gmail.com",
"name": "bruce"
},
"_npmVersion": "2.5.1",
"_phantomChildren": {},
"_requested": {
"name": "temp",
"raw": "temp@0.8.3",
"rawSpec": "0.8.3",
"scope": null,
"spec": "0.8.3",
"type": "version"
},
"_requiredBy": [
"/metro"
],
"_resolved": "https://registry.npmjs.org/temp/-/temp-0.8.3.tgz",
"_shasum": "e0c6bc4d26b903124410e4fed81103014dfc1f59",
"_shrinkwrap": null,
"_spec": "temp@0.8.3",
"_where": "/home/bernhard/freifunk-app/node_modules/metro",
"author": {
"email": "brwcodes@gmail.com",
"name": "Bruce Williams"
},
"bugs": {
"url": "https://github.com/bruce/node-temp/issues"
},
"dependencies": {
"os-tmpdir": "^1.0.0",
"rimraf": "~2.2.6"
},
"description": "Temporary files and directories",
"devDependencies": {},
"directories": {
"lib": "lib"
},
"dist": {
"shasum": "e0c6bc4d26b903124410e4fed81103014dfc1f59",
"tarball": "https://registry.npmjs.org/temp/-/temp-0.8.3.tgz"
},
"engines": [
"node >=0.8.0"
],
"gitHead": "76966b174840a540c8d1566507f2afcad99a3afa",
"homepage": "https://github.com/bruce/node-temp",
"keywords": [
"temp",
"tempdir",
"tempfile",
"temporary",
"tmp",
"tmpdir",
"tmpfile"
],
"license": "MIT",
"main": "./lib/temp",
"maintainers": [
{
"name": "bruce",
"email": "bruce@codefluency.com"
}
],
"name": "temp",
"optionalDependencies": {},
"readme": "ERROR: No README data found!",
"repository": {
"type": "git",
"url": "git://github.com/bruce/node-temp.git"
},
"scripts": {
"test": "node test/temp-test.js"
},
"tags": [
"security",
"temp",
"tempdir",
"tempfile",
"temporary",
"tmpdir",
"tmpfile"
],
"version": "0.8.3"
}

99
node_modules/temp/test/temp-test.js generated vendored Normal file
View File

@@ -0,0 +1,99 @@
var assert = require('assert');
var path = require('path');
var fs = require('fs');
var util = require('util');
var temp = require('../lib/temp');
temp.track();
var existsSync = function(path){
try {
fs.statSync(path);
return true;
} catch (e){
return false;
}
};
// Use path.exists for 0.6 if necessary
var safeExists = fs.exists || path.exists;
var mkdirFired = false;
var mkdirPath = null;
temp.mkdir('foo', function(err, tpath) {
mkdirFired = true;
assert.ok(!err, "temp.mkdir did not execute without errors");
assert.ok(path.basename(tpath).slice(0, 3) == 'foo', 'temp.mkdir did not use the prefix');
assert.ok(existsSync(tpath), 'temp.mkdir did not create the directory');
fs.writeFileSync(path.join(tpath, 'a file'), 'a content');
temp.cleanupSync();
assert.ok(!existsSync(tpath), 'temp.cleanupSync did not remove the directory');
mkdirPath = tpath;
});
var openFired = false;
var openPath = null;
temp.open('bar', function(err, info) {
openFired = true;
assert.equal('object', typeof(info), "temp.open did not invoke the callback with the err and info object");
assert.equal('number', typeof(info.fd), 'temp.open did not invoke the callback with an fd');
fs.writeSync(info.fd, 'foo');
fs.closeSync(info.fd);
assert.equal('string', typeof(info.path), 'temp.open did not invoke the callback with a path');
assert.ok(existsSync(info.path), 'temp.open did not create a file');
temp.cleanupSync();
assert.ok(!existsSync(info.path), 'temp.cleanupSync did not remove the file');
openPath = info.path;
});
var stream = temp.createWriteStream('baz');
assert.ok(stream instanceof fs.WriteStream, 'temp.createWriteStream did not invoke the callback with the err and stream object');
stream.write('foo');
stream.end("More text here\nand more...");
assert.ok(existsSync(stream.path), 'temp.createWriteStream did not create a file');
var tempDir = temp.mkdirSync("foobar");
assert.ok(existsSync(tempDir), 'temp.mkdirTemp did not create a directory');
// cleanupSync()
temp.cleanupSync();
assert.ok(!existsSync(stream.path), 'temp.cleanupSync did not remove the createWriteStream file');
assert.ok(!existsSync(tempDir), 'temp.cleanupSync did not remove the mkdirSync directory');
// cleanup()
var cleanupFired = false;
// Make a temp file just to cleanup
var tempFile = temp.openSync();
fs.writeSync(tempFile.fd, 'foo');
fs.closeSync(tempFile.fd);
assert.ok(existsSync(tempFile.path), 'temp.openSync did not create a file for cleanup');
// run cleanup()
temp.cleanup(function(err, counts) {
cleanupFired = true;
assert.ok(!err, 'temp.cleanup did not run without encountering an error');
assert.ok(!existsSync(tempFile.path), 'temp.cleanup did not remove the openSync file for cleanup');
assert.equal(1, counts.files, 'temp.cleanup did not report the correct removal statistics');
});
var tempPath = temp.path();
assert.ok(path.dirname(tempPath) === temp.dir, "temp.path does not work in default os temporary directory");
tempPath = temp.path({dir: process.cwd()});
assert.ok(path.dirname(tempPath) === process.cwd(), "temp.path does not work in user-provided temporary directory");
for (var i=0; i <= 10; i++) {
temp.openSync();
}
assert.equal(process.listeners('exit').length, 1, 'temp created more than one listener for exit');
process.addListener('exit', function() {
assert.ok(mkdirFired, "temp.mkdir callback did not fire");
assert.ok(openFired, "temp.open callback did not fire");
assert.ok(cleanupFired, "temp.cleanup callback did not fire");
});