Comparing version 1.0.2 to 2.0.0
export declare function getTempName(prefix?: string | null | undefined): string; | ||
export interface GetTempFileOptions { | ||
disposer: ((file: string) => Promise<void>) | null; | ||
prefix?: string | null; | ||
} | ||
export declare class TmpDir { | ||
@@ -7,5 +11,5 @@ private tempFiles; | ||
createTempDir(suffix?: string): Promise<string>; | ||
getTempFile(suffix: string, isDir?: boolean, disposer?: ((file: string) => Promise<void>) | null): Promise<string>; | ||
getTempFile(suffix: string | null, isDir?: boolean, options?: GetTempFileOptions): Promise<string>; | ||
cleanupSync(): void; | ||
cleanup(): Promise<any>; | ||
} |
@@ -105,3 +105,3 @@ "use strict"; | ||
let isDir = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : false; | ||
let disposer = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : null; | ||
let options = arguments[2]; | ||
@@ -113,4 +113,10 @@ return tempDir.value.then(it => { | ||
} | ||
const result = `${it}${_path.sep}${(tmpFileCounter++).toString(16)}${suffix.length === 0 || suffix.startsWith(".") ? suffix : `-${suffix}`}`; | ||
this.tempFiles.push({ path: result, isDir, disposer }); | ||
const namePrefix = options == null || options.prefix == null ? "" : options.prefix; | ||
const nameSuffix = suffix == null || suffix.length === 0 ? "" : suffix.startsWith(".") ? suffix : `-${suffix}`; | ||
const result = `${it}${_path.sep}${namePrefix}${(tmpFileCounter++).toString(16)}${nameSuffix}`; | ||
this.tempFiles.push({ | ||
path: result, | ||
isDir, | ||
disposer: options == null ? null : options.disposer | ||
}); | ||
return result; | ||
@@ -117,0 +123,0 @@ }); |
{ | ||
"name": "temp-file", | ||
"version": "1.0.2", | ||
"version": "2.0.0", | ||
"main": "out/main.js", | ||
@@ -24,6 +24,6 @@ "author": "Vladimir Krivosheev", | ||
"devDependencies": { | ||
"@types/js-yaml": "^3.9.0", | ||
"@types/node": "^8.0.20", | ||
"@types/js-yaml": "^3.9.1", | ||
"@types/node": "^8.0.24", | ||
"babel-preset-ts-node4-bluebird": "^0.1.0", | ||
"ts-babel": "^3.2.1", | ||
"ts-babel": "^4.0.1", | ||
"typescript": "^2.4.2" | ||
@@ -30,0 +30,0 @@ }, |
Sorry, the diff of this file is not supported yet
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
17635
163