Commit a9c6eac5 authored by Alexandra Rogova's avatar Alexandra Rogova

added second script, randomly generates words, sentences and paragraphs to add...

added second script, randomly generates words, sentences and paragraphs to add to the db (1 par = 1 index entry)
parent f7134452
var os = require('os');
var randomstring = require("randomstring");
var tmp = require('tmp');
var fs = require('fs');
var args = require("yargs")
.usage("Usage : load_index.js -saveAs metadata/attachment -p Number of random paragraphs to generate")
.demandOption(['saveAs'])
.demandOption(['paragraphs'])
.alias("p", "paragraphs")
.alias("s", "saveAs")
.describe("paragraphs", "Number of random paragraphs to generate")
.describe("saveAs", "choose whether to save the index as metadata or attachments in the indexeddb")
.nargs("saveAs", 1)
.nargs("paragraphs", 1)
.argv;
var gen_rdm_string = function (length){
return randomstring.generate({
length: length,
charset: 'alphabetic'
});
}
var gen_rdm_sentence = function (word_count, word_length){
var tmp_word_array = [];
for (var i = 0; i<word_count; i+=1){
tmp_word_array[i] = gen_rdm_string(word_length);
}
return tmp_word_array.join(" ");
}
var gen_rdm_paragraph = function (sentence_count, words_per_sentence, word_length){
var tmp_sentence_array = [];
for (var i=0; i<sentence_count; i+=1){
tmp_sentence_array[i] = gen_rdm_sentence(words_per_sentence, word_length);
}
return tmp_sentence_array.join(". ");
}
if (!(args.saveAs === "metadata" ||args.saveAs === "attachment")){
throw 'Unrecognized save as argument';
}
var saveAs = args.saveAs;
const puppeteer = require('puppeteer');
var browser, page, ramBefore, memBefore;
const si = require("systeminformation");
var Server = require('ws').Server;
var port = 9030;
var ws = new Server({port: port});
ws.on('connection', function(w){
w.on('message', function(msg){
console.log(msg);
var ramAfter = (os.totalmem() - os.freemem()) / 1024 / 1024;
var ramUsed = ramAfter - ramBefore;
console.log("Ram used : " + ramUsed + " MB");
si.mem(function(data){
console.log("Memory used : " + (data.used / 1024 / 1024 - memBefore) + " MB");
});
browser.close();
});
w.on('close', function() {
ws.close();
});
});
(async () => {
browser = await puppeteer.launch();
page = await browser.newPage();
ramBefore = (os.totalmem() - os.freemem()) / 1024 / 1024;
si.mem(function(data){
memBefore = data.used / 1024 / 1024;
});
var tmp_para_array = [];
for(var i=0; i<args.p; i+=1){
tmp_para_array[i] = gen_rdm_paragraph(6, 15, 5);
}
var tmp_file = tmp.fileSync();
fs.writeFileSync(tmp_file.name, tmp_para_array.join("\n"));
await page.goto('https://softinst115787.host.vifib.net/public/unit_tests/index_load.html?saveAs='+saveAs);
const [fileChooser] = await Promise.all([
page.waitForFileChooser(),
page.click('input#load')
]);
await fileChooser.accept([tmp_file.name]);
})();
#!/bin/sh
basedir=$(dirname "$(echo "$0" | sed -e 's,\\,/,g')")
case `uname` in
*CYGWIN*) basedir=`cygpath -w "$basedir"`;;
esac
if [ -x "$basedir/node" ]; then
"$basedir/node" "$basedir/../randomstring/bin/randomstring" "$@"
ret=$?
else
node "$basedir/../randomstring/bin/randomstring" "$@"
ret=$?
fi
exit $ret
@IF EXIST "%~dp0\node.exe" (
"%~dp0\node.exe" "%~dp0\..\randomstring\bin\randomstring" %*
) ELSE (
@SETLOCAL
@SET PATHEXT=%PATHEXT:;.JS;=;%
node "%~dp0\..\randomstring\bin\randomstring" %*
)
\ No newline at end of file
'use strict';
// there's 3 implementations written in increasing order of efficiency
// 1 - no Set type is defined
function uniqNoSet(arr) {
var ret = [];
for (var i = 0; i < arr.length; i++) {
if (ret.indexOf(arr[i]) === -1) {
ret.push(arr[i]);
}
}
return ret;
}
// 2 - a simple Set type is defined
function uniqSet(arr) {
var seen = new Set();
return arr.filter(function (el) {
if (!seen.has(el)) {
seen.add(el);
return true;
}
});
}
// 3 - a standard Set type is defined and it has a forEach method
function uniqSetWithForEach(arr) {
var ret = [];
(new Set(arr)).forEach(function (el) {
ret.push(el);
});
return ret;
}
// V8 currently has a broken implementation
// https://github.com/joyent/node/issues/8449
function doesForEachActuallyWork() {
var ret = false;
(new Set([true])).forEach(function (el) {
ret = el;
});
return ret === true;
}
if ('Set' in global) {
if (typeof Set.prototype.forEach === 'function' && doesForEachActuallyWork()) {
module.exports = uniqSetWithForEach;
} else {
module.exports = uniqSet;
}
} else {
module.exports = uniqNoSet;
}
{
"_from": "array-uniq@1.0.2",
"_id": "array-uniq@1.0.2",
"_inBundle": false,
"_integrity": "sha1-X8w3OSB3VyPP1k1lxkvvU7+eum0=",
"_location": "/array-uniq",
"_phantomChildren": {},
"_requested": {
"type": "version",
"registry": true,
"raw": "array-uniq@1.0.2",
"name": "array-uniq",
"escapedName": "array-uniq",
"rawSpec": "1.0.2",
"saveSpec": null,
"fetchSpec": "1.0.2"
},
"_requiredBy": [
"/randomstring"
],
"_resolved": "https://registry.npmjs.org/array-uniq/-/array-uniq-1.0.2.tgz",
"_shasum": "5fcc373920775723cfd64d65c64bef53bf9eba6d",
"_spec": "array-uniq@1.0.2",
"_where": "C:\\Users\\thequ\\Documents\\Mynij\\node_modules\\randomstring",
"author": {
"name": "Sindre Sorhus",
"email": "sindresorhus@gmail.com",
"url": "http://sindresorhus.com"
},
"bugs": {
"url": "https://github.com/sindresorhus/array-uniq/issues"
},
"bundleDependencies": false,
"deprecated": false,
"description": "Create an array without duplicates",
"devDependencies": {
"es6-set": "^0.1.0",
"mocha": "*",
"require-uncached": "^1.0.2"
},
"engines": {
"node": ">=0.10.0"
},
"files": [
"index.js"
],
"homepage": "https://github.com/sindresorhus/array-uniq#readme",
"keywords": [
"array",
"arr",
"set",
"uniq",
"unique",
"es6",
"duplicate",
"remove"
],
"license": "MIT",
"name": "array-uniq",
"repository": {
"type": "git",
"url": "git+https://github.com/sindresorhus/array-uniq.git"
},
"scripts": {
"test": "mocha"
},
"version": "1.0.2"
}
# array-uniq [![Build Status](https://travis-ci.org/sindresorhus/array-uniq.svg?branch=master)](https://travis-ci.org/sindresorhus/array-uniq)
> Create an array without duplicates
It's already pretty fast, but will be much faster when [Set](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Set) becomes available in V8 (especially with large arrays).
## Install
```sh
$ npm install --save array-uniq
```
## Usage
```js
var arrayUniq = require('array-uniq');
arrayUniq([1, 1, 2, 3, 3]);
//=> [1, 2, 3]
arrayUniq(['foo', 'foo', 'bar', 'foo']);
//=> ['foo', 'bar']
```
## License
MIT © [Sindre Sorhus](http://sindresorhus.com)
.DS_Store
*.log
test.js
\ No newline at end of file
language: node_js
node_js:
- "0.12"
- "0.11"
- "0.10"
- "iojs"
- "iojs-v1.0.4"
\ No newline at end of file
1.1.5 / May 18, 2016
==================
* Optimized character generation algorithm
1.1.4 / Feb 10, 2016
==================
* Added option for capitalization
1.1.3 / Nov 03, 2015
==================
* Fixed test
1.1.2 / Nov 03, 2015
==================
* Added command line support
* Fixed bug causing the "readable" option to fail
1.1.0 / Sep 06, 2015
==================
* Added support for custom character sets
* Added option for excluding poorly readable characters
1.0.8 / Sep 01, 2015
==================
* Avoid problems if crypto.randomBytes throws an exception
1.0.7 / Jul 03, 2015
==================
* Use node.crypto instead of Math.random as random number generator
1.0.6 / Jun 01, 2015
==================
* Added licence for npmjs.org
* Enhanced readme for Github and npm
1.0.5 / Apr 03, 2015
==================
* Better charset setting → Less error-proneness
1.0.4 / Apr 03, 2015
==================
* Added tests
1.0.3 / Feb 17, 2014
==================
* Fixed typo in character set
1.0.0 / Jan 21, 2012
==================
* Start of the project
\ No newline at end of file
Copyright (c) 2012 Elias Klughammer
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.
# node-randomstring
[![Build Status](https://travis-ci.org/klughammer/node-randomstring.svg?branch=master)](https://travis-ci.org/klughammer/node-randomstring) [![Download Stats](https://img.shields.io/npm/dm/randomstring.svg)](https://github.com/klughammer/node-randomstring)
Library to help you create random strings.
## Installation
To install randomstring, use [npm](http://github.com/npm/npm):
```
npm install randomstring
```
## Usage
```javascript
var randomstring = require("randomstring");
randomstring.generate();
// >> "XwPp9xazJ0ku5CZnlmgAx2Dld8SHkAeT"
randomstring.generate(7);
// >> "xqm5wXX"
randomstring.generate({
length: 12,
charset: 'alphabetic'
});
// >> "AqoTIzKurxJi"
randomstring.generate({
charset: 'abc'
});
// >> "accbaabbbbcccbccccaacacbbcbbcbbc"
```
## API
`randomstring.`
- `generate(options)`
- `length` - the length of the random string. (default: 32) [OPTIONAL]
- `readable` - exclude poorly readable chars: 0OIl. (default: false) [OPTIONAL]
- `charset` - define the character set for the string. (default: 'alphanumeric') [OPTIONAL]
- `alphanumeric` - [0-9 a-z A-Z]
- `alphabetic` - [a-z A-Z]
- `numeric` - [0-9]
- `hex` - [0-9 a-f]
- `custom` - any given characters
- `capitalization` - define whether the output should be lowercase / uppercase only. (default: null) [OPTIONAL]
- `lowercase`
- `uppercase`
## Command Line Usage
$ npm install -g randomstring
$ randomstring
> sKCx49VgtHZ59bJOTLcU0Gr06ogUnDJi
$ randomstring 7
> CpMg433
$ randomstring length=24 charset=github readable
> hthbtgiguihgbuttuutubugg
## Tests
```
npm install
npm test
```
## LICENSE
node-randomstring is licensed under the MIT license.
#!/usr/bin/env node
var randomstring = require('..');
var options = {};
for (var i = 2, ii = process.argv.length; i < ii; i++) {
var arg = process.argv[i];
if (arg.search('length') >= 0) {
var length = arg.split('=')[1];
if (length)
options.length = parseInt(length);
}
else if (arg.search('readable') >= 0) {
options.readable = true;
}
else if (arg.search('charset') >= 0) {
var charset = arg.split('=')[1];
if (charset)
options.charset = charset;
}
else if (arg.search('capitalization') >= 0) {
var capitalization = arg.split('=')[1];
if (capitalization)
options.capitalization = capitalization;
}
// If only a number is given as an arg, parse it as the length
else if (arg.search(/\D/ig) < 0) {
options.length = parseInt(arg);
}
};
var result = randomstring.generate(options);
console.log(result)
\ No newline at end of file
module.exports = require("./lib/randomstring");
\ No newline at end of file
var arrayUniq = require('array-uniq');
function Charset() {
this.chars = '';
}
Charset.prototype.setType = function(type) {
var chars;
var numbers = '0123456789';
var charsLower = 'abcdefghijklmnopqrstuvwxyz';
var charsUpper = charsLower.toUpperCase();
var hexChars = 'abcdef';
if (type === 'alphanumeric') {
chars = numbers + charsLower + charsUpper;
}
else if (type === 'numeric') {
chars = numbers;
}
else if (type === 'alphabetic') {
chars = charsLower + charsUpper;
}
else if (type === 'hex') {
chars = numbers + hexChars;
}
else {
chars = type;
}
this.chars = chars;
}
Charset.prototype.removeUnreadable = function() {
var unreadableChars = /[0OIl]/g;
this.chars = this.chars.replace(unreadableChars, '');
}
Charset.prototype.setcapitalization = function(capitalization) {
if (capitalization === 'uppercase') {
this.chars = this.chars.toUpperCase();
}
else if (capitalization === 'lowercase') {
this.chars = this.chars.toLowerCase();
}
}
Charset.prototype.removeDuplicates = function() {
var charMap = this.chars.split('');
charMap = arrayUniq(charMap);
this.chars = charMap.join('');
}
module.exports = exports = Charset;
\ No newline at end of file
"use strict";
var crypto = require('crypto');
var Charset = require('./charset.js');
function safeRandomBytes(length) {
while (true) {
try {
return crypto.randomBytes(length);
} catch(e) {
continue;
}
}
}
exports.generate = function(options) {
var charset = new Charset();
var length, chars, capitalization, string = '';
// Handle options
if (typeof options === 'object') {
length = options.length || 32;
if (options.charset) {
charset.setType(options.charset);
}
else {
charset.setType('alphanumeric');
}
if (options.capitalization) {
charset.setcapitalization(options.capitalization);
}
if (options.readable) {
charset.removeUnreadable();
}
charset.removeDuplicates();
}
else if (typeof options === 'number') {
length = options;
charset.setType('alphanumeric');
}
else {
length = 32;
charset.setType('alphanumeric');
}
// Generate the string
var charsLen = charset.chars.length;
var maxByte = 256 - (256 % charsLen);
while (length > 0) {
var buf = safeRandomBytes(Math.ceil(length * 256 / maxByte));
for (var i = 0; i < buf.length && length > 0; i++) {
var randomByte = buf.readUInt8(i);
if (randomByte < maxByte) {
string += charset.chars.charAt(randomByte % charsLen);
length--;
}
}
}
return string;
};
{
"_from": "randomstring",
"_id": "randomstring@1.1.5",
"_inBundle": false,
"_integrity": "sha1-bfBij3XL1ZMpMNn+OrTpVqGFGMM=",
"_location": "/randomstring",
"_phantomChildren": {},
"_requested": {
"type": "tag",
"registry": true,
"raw": "randomstring",
"name": "randomstring",
"escapedName": "randomstring",
"rawSpec": "",
"saveSpec": null,
"fetchSpec": "latest"
},
"_requiredBy": [
"#USER",
"/"
],
"_resolved": "https://registry.npmjs.org/randomstring/-/randomstring-1.1.5.tgz",
"_shasum": "6df0628f75cbd5932930d9fe3ab4e956a18518c3",
"_spec": "randomstring",
"_where": "C:\\Users\\thequ\\Documents\\Mynij",
"author": {
"name": "Elias Klughammer",
"email": "elias@klughammer.com",
"url": "http://www.klughammer.com"
},
"bin": {
"randomstring": "bin/randomstring"
},
"bugs": {
"url": "https://github.com/klughammer/node-randomstring/issues"
},
"bundleDependencies": false,
"dependencies": {
"array-uniq": "1.0.2"
},
"deprecated": false,
"description": "A module for generating random strings",
"devDependencies": {
"mocha": "^1.20.1"
},
"engines": {
"node": "*"
},
"homepage": "https://github.com/klughammer/node-randomstring",
"license": "MIT",
"main": "./index",
"name": "randomstring",
"repository": {
"type": "git",
"url": "git://github.com/klughammer/node-randomstring.git"
},
"scripts": {
"test": "mocha"
},
"version": "1.1.5"
}
"use strict";
var assert = require("assert");
var random = require("..").generate;
var testLength = 24700;
describe("randomstring.generate(options)", function() {
it("returns a string", function() {
var rds = random();
assert.equal(typeof(rds), "string");
});
it("defaults to 32 characters in length", function() {
assert.equal(random().length, 32);
});
it("accepts length as an optional first argument", function() {
assert.equal(random(10).length, 10);
});
it("accepts length as an option param", function() {
assert.equal(random({ length: 7 }).length, 7);
});
it("accepts 'numeric' as charset option", function() {
var testData = random({ length: testLength, charset: 'numeric' });
var search = testData.search(/\D/ig);
assert.equal(search, -1);
});
it("accepts 'alphabetic' as charset option", function() {
var testData = random({ length: testLength, charset: 'alphabetic' });
var search = testData.search(/\d/ig);
assert.equal(search, -1);
});
it("accepts 'hex' as charset option", function() {
var testData = random({ length: testLength, charset: 'hex' });
var search = testData.search(/[^0-9a-f]/ig);
assert.equal(search, -1);
});
it("accepts custom charset", function() {
var charset = "abc";
var testData = random({ length: testLength, charset: charset });
var search = testData.search(/[^abc]/ig);
assert.equal(search, -1);
});
it("accepts readable option", function() {
var testData = random({ length: testLength, readable: true });
var search = testData.search(/[0OIl]/g);
assert.equal(search, -1);
});
it("accepts 'uppercase' as capitalization option", function() {
var testData = random({ length: testLength, capitalization: 'uppercase'});
var search = testData.search(/[a-z]/g);
assert.equal(search, -1);
});
it("accepts 'lowercase' as capitalization option", function() {
var testData = random({ length: testLength, capitalization: 'lowercase'});
var search = testData.search(/[A-Z]/g);
assert.equal(search, -1);
});
it("returns unique strings", function() {
var results = {};
for (var i = 0; i < 1000; i++) {
var s = random();
assert.notEqual(results[s], true);
results[s] = true;
}
return true;
});
it("returns unbiased strings", function() {
var charset = 'abcdefghijklmnopqrstuvwxyz';
var slen = 100000;
var s = random({ charset: charset, length: slen });
var counts = {};
for (var i = 0; i < s.length; i++) {
var c = s.charAt(i);
if (typeof counts[c] === "undefined") {
counts[c] = 0;
} else {
counts[c]++;
}
}
var avg = slen / charset.length;
Object.keys(counts).sort().forEach(function(k) {
var diff = counts[k] / avg;
assert(diff > 0.95 && diff < 1.05,
"bias on `" + k + "': expected average is " + avg + ", got " + counts[k]);
});
});
});
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.
# Tmp
A simple temporary file and directory creator for [node.js.][1]
[![Build Status](https://travis-ci.org/raszi/node-tmp.svg?branch=master)](https://travis-ci.org/raszi/node-tmp)
[![Dependencies](https://david-dm.org/raszi/node-tmp.svg)](https://david-dm.org/raszi/node-tmp)
[![npm version](https://badge.fury.io/js/tmp.svg)](https://badge.fury.io/js/tmp)
[![API documented](https://img.shields.io/badge/API-documented-brightgreen.svg)](https://raszi.github.io/node-tmp/)
[![Known Vulnerabilities](https://snyk.io/test/npm/tmp/badge.svg)](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
/*!
* 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;
{
"_from": "tmp",
"_id": "tmp@0.1.0",
"_inBundle": false,
"_integrity": "sha512-J7Z2K08jbGcdA1kkQpJSqLF6T0tdQqpR2pnSUXsIchbPdTI9v3e85cLW0d6WDhwuAleOV71j2xWs8qMPfK7nKw==",
"_location": "/tmp",
"_phantomChildren": {},
"_requested": {
"type": "tag",
"registry": true,
"raw": "tmp",
"name": "tmp",
"escapedName": "tmp",
"rawSpec": "",
"saveSpec": null,
"fetchSpec": "latest"
},
"_requiredBy": [
"#USER",
"/"
],
"_resolved": "https://registry.npmjs.org/tmp/-/tmp-0.1.0.tgz",
"_shasum": "ee434a4e22543082e294ba6201dcc6eafefa2877",
"_spec": "tmp",
"_where": "C:\\Users\\thequ\\Documents\\Mynij",
"author": {
"name": "KARASZI István",
"email": "github@spam.raszi.hu",
"url": "http://raszi.hu/"
},
"bugs": {
"url": "http://github.com/raszi/node-tmp/issues"
},
"bundleDependencies": false,
"dependencies": {
"rimraf": "^2.6.3"
},
"deprecated": false,
"description": "Temporary file and directory creator",
"devDependencies": {
"eslint": "^4.19.1",
"eslint-plugin-mocha": "^5.0.0",
"istanbul": "^0.4.5",
"mocha": "^5.1.1"
},
"engines": {
"node": ">=6"
},
"files": [
"lib/"
],
"homepage": "http://github.com/raszi/node-tmp",
"keywords": [
"temporary",
"tmp",
"temp",
"tempdir",
"tempfile",
"tmpdir",
"tmpfile"
],
"license": "MIT",
"main": "lib/tmp.js",
"name": "tmp",
"repository": {
"type": "git",
"url": "git+https://github.com/raszi/node-tmp.git"
},
"scripts": {
"clean": "rm -Rf ./coverage",
"doc": "jsdoc -c .jsdoc.json",
"lint": "eslint lib --env mocha test",
"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"
},
"version": "0.1.0"
}
......@@ -23,6 +23,11 @@
"color-convert": "^1.9.0"
}
},
"array-uniq": {
"version": "1.0.2",
"resolved": "https://registry.npmjs.org/array-uniq/-/array-uniq-1.0.2.tgz",
"integrity": "sha1-X8w3OSB3VyPP1k1lxkvvU7+eum0="
},
"async-limiter": {
"version": "1.0.1",
"resolved": "https://registry.npmjs.org/async-limiter/-/async-limiter-1.0.1.tgz",
......@@ -349,6 +354,14 @@
"ws": "^6.1.0"
}
},
"randomstring": {
"version": "1.1.5",
"resolved": "https://registry.npmjs.org/randomstring/-/randomstring-1.1.5.tgz",
"integrity": "sha1-bfBij3XL1ZMpMNn+OrTpVqGFGMM=",
"requires": {
"array-uniq": "1.0.2"
}
},
"readable-stream": {
"version": "2.3.6",
"resolved": "https://registry.npmjs.org/readable-stream/-/readable-stream-2.3.6.tgz",
......@@ -422,6 +435,14 @@
"resolved": "https://registry.npmjs.org/systeminformation/-/systeminformation-4.14.11.tgz",
"integrity": "sha512-KlMaQQftyGUPjKzGRrATN5mpKrpdtrVk/KPuqPeu733bUgpokIhevg5zjKOb4Gur91XKdbdQCCja/oFsg5R4Dw=="
},
"tmp": {
"version": "0.1.0",
"resolved": "https://registry.npmjs.org/tmp/-/tmp-0.1.0.tgz",
"integrity": "sha512-J7Z2K08jbGcdA1kkQpJSqLF6T0tdQqpR2pnSUXsIchbPdTI9v3e85cLW0d6WDhwuAleOV71j2xWs8qMPfK7nKw==",
"requires": {
"rimraf": "^2.6.3"
}
},
"typedarray": {
"version": "0.0.6",
"resolved": "https://registry.npmjs.org/typedarray/-/typedarray-0.0.6.tgz",
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment