mirror of
https://github.com/tiennm99/FBcount.git
synced 2026-08-17 03:41:59 +00:00
Init
This commit is contained in:
+25
@@ -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);
|
||||
};
|
||||
}
|
||||
+21
@@ -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.
|
||||
+72
@@ -0,0 +1,72 @@
|
||||
{
|
||||
"_from": "unique-temp-dir@^1.0.0",
|
||||
"_id": "unique-temp-dir@1.0.0",
|
||||
"_inBundle": false,
|
||||
"_integrity": "sha1-bc6VsmgcoAPuv7MEpBX5y6vMU4U=",
|
||||
"_location": "/unique-temp-dir",
|
||||
"_phantomChildren": {},
|
||||
"_requested": {
|
||||
"type": "range",
|
||||
"registry": true,
|
||||
"raw": "unique-temp-dir@^1.0.0",
|
||||
"name": "unique-temp-dir",
|
||||
"escapedName": "unique-temp-dir",
|
||||
"rawSpec": "^1.0.0",
|
||||
"saveSpec": null,
|
||||
"fetchSpec": "^1.0.0"
|
||||
},
|
||||
"_requiredBy": [
|
||||
"/pkg-fetch"
|
||||
],
|
||||
"_resolved": "https://registry.npmjs.org/unique-temp-dir/-/unique-temp-dir-1.0.0.tgz",
|
||||
"_shasum": "6dce95b2681ca003eebfb304a415f9cbabcc5385",
|
||||
"_spec": "unique-temp-dir@^1.0.0",
|
||||
"_where": "/home/miti99/Dropbox/Workspace/FBcount/Nodejs/node_modules/pkg-fetch",
|
||||
"author": {
|
||||
"name": "James Talmage",
|
||||
"email": "james@talmage.io",
|
||||
"url": "github.com/jamestalmage"
|
||||
},
|
||||
"bugs": {
|
||||
"url": "https://github.com/jamestalmage/unique-temp-dir/issues"
|
||||
},
|
||||
"bundleDependencies": false,
|
||||
"dependencies": {
|
||||
"mkdirp": "^0.5.1",
|
||||
"os-tmpdir": "^1.0.1",
|
||||
"uid2": "0.0.3"
|
||||
},
|
||||
"deprecated": false,
|
||||
"description": "Provides a uniquely named temp directory.",
|
||||
"devDependencies": {
|
||||
"ava": "^0.8.0",
|
||||
"xo": "^0.12.1"
|
||||
},
|
||||
"engines": {
|
||||
"node": ">=0.10.0"
|
||||
},
|
||||
"files": [
|
||||
"index.js"
|
||||
],
|
||||
"homepage": "https://github.com/jamestalmage/unique-temp-dir#readme",
|
||||
"keywords": [
|
||||
"unique",
|
||||
"temp",
|
||||
"temporary",
|
||||
"directory",
|
||||
"dir",
|
||||
"cross",
|
||||
"platform",
|
||||
"os"
|
||||
],
|
||||
"license": "MIT",
|
||||
"name": "unique-temp-dir",
|
||||
"repository": {
|
||||
"type": "git",
|
||||
"url": "git+https://github.com/jamestalmage/unique-temp-dir.git"
|
||||
},
|
||||
"scripts": {
|
||||
"test": "xo && ava"
|
||||
},
|
||||
"version": "1.0.0"
|
||||
}
|
||||
+71
@@ -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)
|
||||
Reference in New Issue
Block a user