mirror of
https://github.com/balena-io/etcher.git
synced 2025-04-21 05:47:18 +00:00

Changelog-entry: Remove bluebird from main process, reduce lodash usage Change-type: patch
25 lines
581 B
TypeScript
25 lines
581 B
TypeScript
import * as Bluebird from 'bluebird';
|
|
import * as tmp from 'tmp';
|
|
|
|
function tmpFileAsync(
|
|
options: tmp.FileOptions,
|
|
): Promise<{ path: string; cleanup: () => void }> {
|
|
return new Promise((resolve, reject) => {
|
|
tmp.file(options, (error, path, _fd, cleanup) => {
|
|
if (error) {
|
|
reject(error);
|
|
} else {
|
|
resolve({ path, cleanup });
|
|
}
|
|
});
|
|
});
|
|
}
|
|
|
|
export function tmpFileDisposer(
|
|
options: tmp.FileOptions,
|
|
): Bluebird.Disposer<{ path: string; cleanup: () => void }> {
|
|
return Bluebird.resolve(tmpFileAsync(options)).disposer(({ cleanup }) => {
|
|
cleanup();
|
|
});
|
|
}
|