本文整理匯總了TypeScript中temp.cleanup函數的典型用法代碼示例。如果您正苦於以下問題:TypeScript cleanup函數的具體用法?TypeScript cleanup怎麽用?TypeScript cleanup使用的例子?那麽, 這裏精選的函數代碼示例或許可以為您提供幫助。
在下文中一共展示了cleanup函數的2個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的TypeScript代碼示例。
示例1: terminate
function terminate(ex: unknown): void {
// We don't want to handle exceptions that happen while we're terminating.
if (terminating) {
if (ex != null) {
process.stderr.write(`${prog}: got error while terminating\n`);
process.stderr.write(util.inspect(ex));
}
return;
}
terminating = true;
if (ex != null) {
if (ex instanceof Fatal) {
process.stderr.write(`${prog}: ${ex.message}\n`);
process.exit(1);
}
else {
if (!args || !args.keep_temp) {
temp.cleanup(); // We need to do this ourselves...
}
throw ex;
}
}
}
示例2: testCleanup
function testCleanup() {
temp.cleanup(result => {
if (typeof result === "boolean") {
const x = result;
} else {
const { files, dirs } = result;
files.toPrecision(4);
files.toPrecision(4);
}
});
}