cdbrelease/withtemp.js
Aaron Suen 8362e41b0e Metadata editing, releasing via the API
Left to do:
- test out including commit hash, when ruben
  finishes implementing this in the API.
- screenshot reconciliation.
2021-02-27 11:20:52 -05:00

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;