Comparing version 0.2.1 to 0.3.0
23
index.js
@@ -9,22 +9,23 @@ 'use strict'; | ||
module.exports.file = opts => { | ||
opts = Object.assign({ | ||
extension: '' | ||
}, opts); | ||
module.exports.file = options => { | ||
options = { | ||
extension: '', | ||
...options | ||
}; | ||
if (opts.name) { | ||
if (opts.extension) { | ||
if (options.name) { | ||
if (options.extension) { | ||
throw new Error('The `name` and `extension` options are mutually exclusive'); | ||
} | ||
return path.join(module.exports.directory(), opts.name); | ||
return path.join(module.exports.directory(), options.name); | ||
} | ||
return getPath() + (opts.extension ? `.${opts.extension.replace(/^\./, '')}` : ''); | ||
return getPath() + '.' + options.extension.replace(/^\./, ''); | ||
}; | ||
module.exports.directory = () => { | ||
const dir = getPath(); | ||
fs.mkdirSync(dir); | ||
return dir; | ||
const directory = getPath(); | ||
fs.mkdirSync(directory); | ||
return directory; | ||
}; | ||
@@ -31,0 +32,0 @@ |
{ | ||
"name": "tempy", | ||
"version": "0.2.1", | ||
"version": "0.3.0", | ||
"description": "Get a random temporary file or directory path", | ||
@@ -13,13 +13,13 @@ "license": "MIT", | ||
"engines": { | ||
"node": ">=4" | ||
"node": ">=8" | ||
}, | ||
"scripts": { | ||
"test": "xo && ava" | ||
"test": "xo && ava && tsd" | ||
}, | ||
"files": [ | ||
"index.js" | ||
"index.js", | ||
"index.d.ts" | ||
], | ||
"keywords": [ | ||
"temp", | ||
"tmp", | ||
"temporary", | ||
@@ -29,3 +29,2 @@ "path", | ||
"directory", | ||
"dir", | ||
"folder", | ||
@@ -37,3 +36,2 @@ "tempfile", | ||
"random", | ||
"rand", | ||
"unique", | ||
@@ -44,8 +42,10 @@ "uniq" | ||
"temp-dir": "^1.0.0", | ||
"type-fest": "^0.3.1", | ||
"unique-string": "^1.0.0" | ||
}, | ||
"devDependencies": { | ||
"ava": "*", | ||
"xo": "*" | ||
"ava": "^1.4.1", | ||
"tsd": "^0.7.2", | ||
"xo": "^0.24.0" | ||
} | ||
} |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
5945
5
81
3
3
+ Addedtype-fest@^0.3.1
+ Addedtype-fest@0.3.1(transitive)