DefinitelyTyped/types/promised-temp/promised-temp-tests.ts
Nathan Shively-Sanders 708214ef04 Change 'export default' to 'export =', part 2 (#33823)
* Change 'export default' to 'export ='

For packages that don't actually export a 'default' property.

* 7 more packages
2019-03-12 16:36:10 -07:00

55 lines
1.4 KiB
TypeScript

import * as fs from "fs";
import temp = require("promised-temp");
function testCleanup() {
temp.cleanup().then((result: boolean | temp.Stats) => {
if (typeof result === "boolean") {
const x = result;
} else {
const { files, dirs } = result;
files.toPrecision(4);
}
});
}
function testOpen() {
temp.open({ dir: "tempDir", prefix: "pref", suffix: "suff" }).then((result: temp.OpenFile) => {
const { path, fd } = result;
path.length;
fd.toPrecision(5);
});
temp.open("strPrefix").then((result: temp.OpenFile) => {
const { path, fd } = result;
path.length;
fd.toPrecision(5);
});
}
function testCreateWriteStream() {
const stream =
temp.createWriteStream("HelloStreamAffix")
.then((stream: fs.WriteStream) => stream.write("data"));
const stream2 = temp.createWriteStream();
}
function testMkdir() {
temp.mkdir("prefix").then((dirPath: string) => {
dirPath.length;
});
}
function testPath() {
const p = temp.path({ suffix: "justSuffix" }, "defaultPrefix");
p.length;
const p2: string = temp.path("prefix");
const p3: string = temp.path({ prefix: "prefix" });
}
function testTrack() {
const tempChained = temp.track().track(true).track(false);
tempChained.dir;
tempChained.cleanup();
}