tempfile 1.0.0 → 3.0.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/index.d.ts ADDED
@@ -0,0 +1,19 @@
1
+ /**
2
+ Get a random temporary file path.
3
+
4
+ @param extension - Extension to append to the path.
5
+
6
+ @example
7
+ ```
8
+ import tempfile = require('tempfile');
9
+
10
+ tempfile('.png');
11
+ //=> '/var/folders/3x/jf5977fn79jbglr7rk0tq4d00000gn/T/4049f192-43e7-43b2-98d9-094e6760861b.png'
12
+
13
+ tempfile();
14
+ //=> '/var/folders/3x/jf5977fn79jbglr7rk0tq4d00000gn/T/6271e235-13b9-4138-8b9b-ee2f26c09ce3'
15
+ ```
16
+ */
17
+ declare function tempfile(extension?: string): string;
18
+
19
+ export = tempfile;
package/index.js CHANGED
@@ -1,9 +1,6 @@
1
1
  'use strict';
2
- var path = require('path');
3
- var os = require('os');
4
- var tmpdir = os.tmpdir();
5
- var uuid = require('uuid');
2
+ const path = require('path');
3
+ const uuid = require('uuid');
4
+ const tempDirectory = require('temp-dir');
6
5
 
7
- module.exports = function (ext) {
8
- return path.join(tmpdir, uuid.v4() + (ext || ''));
9
- };
6
+ module.exports = (extension = '') => path.join(tempDirectory, uuid.v4() + extension);
package/license ADDED
@@ -0,0 +1,9 @@
1
+ MIT License
2
+
3
+ Copyright (c) Sindre Sorhus <sindresorhus@gmail.com> (sindresorhus.com)
4
+
5
+ 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:
6
+
7
+ The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
8
+
9
+ 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.
package/package.json CHANGED
@@ -1,37 +1,40 @@
1
1
  {
2
- "name": "tempfile",
3
- "version": "1.0.0",
4
- "description": "Get a random temp file path",
5
- "license": "MIT",
6
- "repository": "sindresorhus/tempfile",
7
- "author": {
8
- "name": "Sindre Sorhus",
9
- "email": "sindresorhus@gmail.com",
10
- "url": "http://sindresorhus.com"
11
- },
12
- "engines": {
13
- "node": ">=0.10.0"
14
- },
15
- "scripts": {
16
- "test": "mocha"
17
- },
18
- "files": [
19
- "index.js"
20
- ],
21
- "keywords": [
22
- "tmp",
23
- "temp",
24
- "temporary",
25
- "tempfile",
26
- "file",
27
- "path",
28
- "random",
29
- "rand"
30
- ],
31
- "dependencies": {
32
- "uuid": "^1.4.0"
33
- },
34
- "devDependencies": {
35
- "mocha": "*"
36
- }
2
+ "name": "tempfile",
3
+ "version": "3.0.0",
4
+ "description": "Get a random temporary file path",
5
+ "license": "MIT",
6
+ "repository": "sindresorhus/tempfile",
7
+ "author": {
8
+ "name": "Sindre Sorhus",
9
+ "email": "sindresorhus@gmail.com",
10
+ "url": "sindresorhus.com"
11
+ },
12
+ "engines": {
13
+ "node": ">=8"
14
+ },
15
+ "scripts": {
16
+ "test": "xo && ava && tsd"
17
+ },
18
+ "files": [
19
+ "index.js",
20
+ "index.d.ts"
21
+ ],
22
+ "keywords": [
23
+ "temp",
24
+ "temporary",
25
+ "tempfile",
26
+ "file",
27
+ "path",
28
+ "random",
29
+ "uuid"
30
+ ],
31
+ "dependencies": {
32
+ "temp-dir": "^2.0.0",
33
+ "uuid": "^3.3.2"
34
+ },
35
+ "devDependencies": {
36
+ "ava": "^1.4.1",
37
+ "tsd": "^0.7.2",
38
+ "xo": "^0.24.0"
39
+ }
37
40
  }
package/readme.md CHANGED
@@ -1,36 +1,47 @@
1
1
  # tempfile [![Build Status](https://travis-ci.org/sindresorhus/tempfile.svg?branch=master)](https://travis-ci.org/sindresorhus/tempfile)
2
2
 
3
- > Get a random temp file path
3
+ > Get a random temporary file path
4
+
5
+ **Checkout out [`tempy`](https://github.com/sindresorhus/tempy) which is a better take on this module.**
4
6
 
5
7
 
6
8
  ## Install
7
9
 
8
- ```sh
9
- $ npm install --save tempfile
10
+ ```
11
+ $ npm install tempfile
10
12
  ```
11
13
 
12
14
 
13
15
  ## Usage
14
16
 
15
17
  ```js
16
- var tempfile = require('tempfile');
18
+ const tempfile = require('tempfile');
17
19
 
18
20
  tempfile('.png');
19
- //=> /var/folders/_1/tk89k8215ts0rg0kmb096nj80000gn/T/4049f192-43e7-43b2-98d9-094e6760861b.png
21
+ //=> '/var/folders/3x/jf5977fn79jbglr7rk0tq4d00000gn/T/4049f192-43e7-43b2-98d9-094e6760861b.png'
22
+
23
+ tempfile();
24
+ //=> '/var/folders/3x/jf5977fn79jbglr7rk0tq4d00000gn/T/6271e235-13b9-4138-8b9b-ee2f26c09ce3'
20
25
  ```
21
26
 
22
27
 
23
28
  ## API
24
29
 
25
- ### tempfile(extension)
30
+ ### tempfile([extension])
26
31
 
27
32
  #### extension
28
33
 
29
34
  Type: `string`
30
35
 
31
- Optionally supply an extension to append to the path.
36
+ Extension to append to the path.
37
+
38
+
39
+ ## Related
40
+
41
+ - [tempy](https://github.com/sindresorhus/tempy) - Get a random temporary file or directory path
42
+ - [temp-write](https://github.com/sindresorhus/temp-write) - Write string/buffer/stream to a random temp file
32
43
 
33
44
 
34
45
  ## License
35
46
 
36
- MIT © [Sindre Sorhus](http://sindresorhus.com)
47
+ MIT © [Sindre Sorhus](https://sindresorhus.com)