8362e41b0e
Left to do: - test out including commit hash, when ruben finishes implementing this in the API. - screenshot reconciliation.
21 lines
389 B
JavaScript
21 lines
389 B
JavaScript
'use strict';
|
|
|
|
const fsx = require('fs-extra');
|
|
const tmp = require('tmp-promise');
|
|
|
|
async function withtemp(func) {
|
|
const tmpdir = await tmp.dir({
|
|
mode: parseInt('700', 8),
|
|
prefix: 'cdbrelease-'
|
|
});
|
|
try {
|
|
await fsx.emptyDir(tmpdir.path);
|
|
return await func(tmpdir.path);
|
|
} finally {
|
|
await fsx.emptyDir(tmpdir.path);
|
|
await tmpdir.cleanup();
|
|
}
|
|
}
|
|
|
|
module.exports = withtemp;
|