diff options
author | Florian Dold <florian.dold@gmail.com> | 2017-05-28 00:38:50 +0200 |
---|---|---|
committer | Florian Dold <florian.dold@gmail.com> | 2017-05-28 00:40:43 +0200 |
commit | 7fff4499fd915bcea3fa93b1aa8b35f4fe7a6027 (patch) | |
tree | 6de9a1aebd150a23b7f8c273ec657a5d0a18fe3e /node_modules/unique-temp-dir | |
parent | 963b7a41feb29cc4be090a2446bdfe0c1f1bcd81 (diff) |
add linting (and some initial fixes)
Diffstat (limited to 'node_modules/unique-temp-dir')
-rw-r--r-- | node_modules/unique-temp-dir/index.js | 25 | ||||
-rw-r--r-- | node_modules/unique-temp-dir/license | 21 | ||||
l--------- | node_modules/unique-temp-dir/node_modules/.bin/mkdirp | 1 | ||||
-rw-r--r-- | node_modules/unique-temp-dir/package.json | 40 | ||||
-rw-r--r-- | node_modules/unique-temp-dir/readme.md | 71 |
5 files changed, 158 insertions, 0 deletions
diff --git a/node_modules/unique-temp-dir/index.js b/node_modules/unique-temp-dir/index.js new file mode 100644 index 000000000..bd4111b07 --- /dev/null +++ b/node_modules/unique-temp-dir/index.js @@ -0,0 +1,25 @@ +'use strict'; +var osTmpdir = require('os-tmpdir'); +var uid2 = require('uid2'); +var mkdirp = require('mkdirp'); +var path = require('path'); + +module.exports = function (options) { + options = options || {}; + var uniqueDir = path.join(osTmpdir(), uid2(options.length || 20)); + if (options.create) { + mkdirp.sync(uniqueDir); + } + if (options.thunk) { + return thunk(uniqueDir); + } + return uniqueDir; +}; + +function thunk(uniquedir) { + return function () { + var args = Array.prototype.slice.call(arguments); + args.unshift(uniquedir); + return path.join.apply(path, args); + }; +} diff --git a/node_modules/unique-temp-dir/license b/node_modules/unique-temp-dir/license new file mode 100644 index 000000000..ad5d021ed --- /dev/null +++ b/node_modules/unique-temp-dir/license @@ -0,0 +1,21 @@ +The MIT License (MIT) + +Copyright (c) James Talmage <james@talmage.io> (github.com/jamestalmage) + +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. diff --git a/node_modules/unique-temp-dir/node_modules/.bin/mkdirp b/node_modules/unique-temp-dir/node_modules/.bin/mkdirp new file mode 120000 index 000000000..91a5f623f --- /dev/null +++ b/node_modules/unique-temp-dir/node_modules/.bin/mkdirp @@ -0,0 +1 @@ +../../../mkdirp/bin/cmd.js
\ No newline at end of file diff --git a/node_modules/unique-temp-dir/package.json b/node_modules/unique-temp-dir/package.json new file mode 100644 index 000000000..dfec1b47f --- /dev/null +++ b/node_modules/unique-temp-dir/package.json @@ -0,0 +1,40 @@ +{ + "name": "unique-temp-dir", + "version": "1.0.0", + "description": "Provides a uniquely named temp directory.", + "license": "MIT", + "repository": "jamestalmage/unique-temp-dir", + "author": { + "name": "James Talmage", + "email": "james@talmage.io", + "url": "github.com/jamestalmage" + }, + "engines": { + "node": ">=0.10.0" + }, + "scripts": { + "test": "xo && ava" + }, + "files": [ + "index.js" + ], + "keywords": [ + "unique", + "temp", + "temporary", + "directory", + "dir", + "cross", + "platform", + "os" + ], + "dependencies": { + "mkdirp": "^0.5.1", + "os-tmpdir": "^1.0.1", + "uid2": "0.0.3" + }, + "devDependencies": { + "ava": "^0.8.0", + "xo": "^0.12.1" + } +} diff --git a/node_modules/unique-temp-dir/readme.md b/node_modules/unique-temp-dir/readme.md new file mode 100644 index 000000000..8b457703b --- /dev/null +++ b/node_modules/unique-temp-dir/readme.md @@ -0,0 +1,71 @@ +# unique-temp-dir [](https://travis-ci.org/jamestalmage/unique-temp-dir) + +> Provides a uniquely named temp directory. + + +## Install + +``` +$ npm install --save unique-temp-dir +``` + + +## Usage + +```js +const uniqueTempDir = require('unique-temp-dir'); + +uniqueTempDir(); +//=> '/var/folders/2_/zg9h6_xd4r3_z7c07s0cn8mw0000gn/T/PpCfz55ANU2hdwnGzgny' + +uniqueTempDir(); +//=> '/var/folders/2_/zg9h6_xd4r3_z7c07s0cn8mw0000gn/T/qfqafhh1FJulehbCDAPk' +``` + + +## API + +### uniqueTempDir([options]) + +Returns a string that represents a unique directory inside the systems temp directory. + +#### options + +##### create + +Type: `boolean` +Default: `false` + +If `true`, the directory will be created synchronously before returning. + +##### length + +Type: `number` +Default: `20` + +The length of the directory name inside the temp directory. + +##### thunk + +Type: `boolean` +Default: `false` + +If true, returns a thunk function for `path.join(uniqueTempDir, ... additionalArgs)`. Useful for filling your directory up with stuff. + +```js +const uniqueTempDir = require('unique-temp-dir'); +const tempDir = uniqueTempDir({thunk: true}); + +tempDir() +//=> /user/temp/uniqueId + +tempDir('foo') +//=> /user/temp/uniqueId/foo + +tempDir('bar') +//=> /user/temp/uniqueId/bar +``` + +## License + +MIT © [James Talmage](http://github.com/jamestalmage) |