From 30cbb6f4d05b84cc128e3aafa266979ed6806a3a Mon Sep 17 00:00:00 2001 From: Jared Date: Fri, 16 Jan 2015 16:36:02 +1300 Subject: [PATCH 1/3] Add definitions for node-tmp library --- tmp/tmp-tests.ts | 46 ++++++++++++++++++++++++++++++++++++++++++++++ tmp/tmp.d.ts | 33 +++++++++++++++++++++++++++++++++ 2 files changed, 79 insertions(+) create mode 100644 tmp/tmp-tests.ts create mode 100644 tmp/tmp.d.ts diff --git a/tmp/tmp-tests.ts b/tmp/tmp-tests.ts new file mode 100644 index 0000000000..2a5c04ffe0 --- /dev/null +++ b/tmp/tmp-tests.ts @@ -0,0 +1,46 @@ +/// +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(); \ No newline at end of file diff --git a/tmp/tmp.d.ts b/tmp/tmp.d.ts new file mode 100644 index 0000000000..018840de66 --- /dev/null +++ b/tmp/tmp.d.ts @@ -0,0 +1,33 @@ +// Type definitions for tmp v0.0.24 +// Project: https://github.com/raszi/node-tmp +// Definitions by: Jared Klopper +// 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; +} \ No newline at end of file From f30495689db458fc6dd8c725bddd012d1ba54d27 Mon Sep 17 00:00:00 2001 From: Jared Date: Fri, 16 Jan 2015 16:39:52 +1300 Subject: [PATCH 2/3] Add missing newline to end of files --- tmp/tmp-tests.ts | 2 +- tmp/tmp.d.ts | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/tmp/tmp-tests.ts b/tmp/tmp-tests.ts index 2a5c04ffe0..7f489eea41 100644 --- a/tmp/tmp-tests.ts +++ b/tmp/tmp-tests.ts @@ -43,4 +43,4 @@ tmp.tmpName({ template: '/tmp/tmp-XXXXXX' }, (err, path) => { console.log("Created temporary filename: ", path); }); -tmp.setGracefulCleanup(); \ No newline at end of file +tmp.setGracefulCleanup(); diff --git a/tmp/tmp.d.ts b/tmp/tmp.d.ts index 018840de66..7fb096d0b2 100644 --- a/tmp/tmp.d.ts +++ b/tmp/tmp.d.ts @@ -30,4 +30,4 @@ declare module "tmp" { } export = tmp; -} \ No newline at end of file +} From 19b1315f33b8ad7ac54c0189f3b4b21f101db058 Mon Sep 17 00:00:00 2001 From: Jared Date: Fri, 16 Jan 2015 21:13:44 +1300 Subject: [PATCH 3/3] Use npmjs link --- tmp/tmp.d.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tmp/tmp.d.ts b/tmp/tmp.d.ts index 7fb096d0b2..a89d7d1c4d 100644 --- a/tmp/tmp.d.ts +++ b/tmp/tmp.d.ts @@ -1,5 +1,5 @@ // Type definitions for tmp v0.0.24 -// Project: https://github.com/raszi/node-tmp +// Project: https://www.npmjs.com/package/tmp // Definitions by: Jared Klopper // Definitions: https://github.com/borisyankov/DefinitelyTyped