mirror of
https://github.com/zhigang1992/DefinitelyTyped.git
synced 2026-04-24 05:06:02 +08:00
Add definitions for node-tmp library
This commit is contained in:
46
tmp/tmp-tests.ts
Normal file
46
tmp/tmp-tests.ts
Normal file
@@ -0,0 +1,46 @@
|
||||
/// <reference path="tmp.d.ts" />
|
||||
import tmp = require('tmp');
|
||||
|
||||
tmp.file((err, path, fd, cleanupCallback) => {
|
||||
if (err) throw err;
|
||||
|
||||
console.log("File: ", path);
|
||||
console.log("Filedescriptor: ", fd);
|
||||
|
||||
cleanupCallback();
|
||||
});
|
||||
|
||||
tmp.dir((err, path, cleanupCallback) => {
|
||||
if (err) throw err;
|
||||
|
||||
console.log("Dir: ", path);
|
||||
|
||||
cleanupCallback();
|
||||
});
|
||||
|
||||
tmp.tmpName((err, path) => {
|
||||
if (err) throw err;
|
||||
|
||||
console.log("Created temporary filename: ", path);
|
||||
});
|
||||
|
||||
tmp.file({ mode: 644, prefix: 'prefix-', postfix: '.txt' }, (err, path, fd) => {
|
||||
if (err) throw err;
|
||||
|
||||
console.log("File: ", path);
|
||||
console.log("Filedescriptor: ", fd);
|
||||
});
|
||||
|
||||
tmp.dir({ mode: 750, prefix: 'myTmpDir_' }, (err, path) => {
|
||||
if (err) throw err;
|
||||
|
||||
console.log("Dir: ", path);
|
||||
});
|
||||
|
||||
tmp.tmpName({ template: '/tmp/tmp-XXXXXX' }, (err, path) => {
|
||||
if (err) throw err;
|
||||
|
||||
console.log("Created temporary filename: ", path);
|
||||
});
|
||||
|
||||
tmp.setGracefulCleanup();
|
||||
33
tmp/tmp.d.ts
vendored
Normal file
33
tmp/tmp.d.ts
vendored
Normal file
@@ -0,0 +1,33 @@
|
||||
// Type definitions for tmp v0.0.24
|
||||
// Project: https://github.com/raszi/node-tmp
|
||||
// Definitions by: Jared Klopper <https://github.com/optical>
|
||||
// Definitions: https://github.com/borisyankov/DefinitelyTyped
|
||||
|
||||
declare module "tmp" {
|
||||
|
||||
module tmp {
|
||||
interface Options {
|
||||
mode?: number;
|
||||
prefix?: string;
|
||||
postfix?: string;
|
||||
template?: string;
|
||||
dir?: string;
|
||||
tries?: number;
|
||||
keep?: boolean;
|
||||
unsafeCleanup?: boolean;
|
||||
}
|
||||
|
||||
function file(callback: (err: any, path: string, fd: number, cleanupCallback: () => void) => void): void;
|
||||
function file(config: Options, callback?: (err: any, path: string, fd: number, cleanupCallback: () => void) => void): void;
|
||||
|
||||
function dir(callback: (err: any, path: string, cleanupCallback: () => void) => void): void;
|
||||
function dir(config: Options, callback?: (err: any, path: string, cleanupCallback: () => void) => void): void;
|
||||
|
||||
function tmpName(callback: (err: any, path: string) => void): void;
|
||||
function tmpName(config: Options, callback?: (err: any, path: string) => void): void;
|
||||
|
||||
function setGracefulCleanup(): void;
|
||||
}
|
||||
|
||||
export = tmp;
|
||||
}
|
||||
Reference in New Issue
Block a user