VulpesOS/gaia/tests/jsmarionette/runner/mozilla-profile-builder/lib/tmpdir.js
OverSu b38dea0597 Publish Vulpes Preview 15 sources for desktop, Android and Tundra
Share Gaia assets and adapters, keep private profiles and development documents local, and update both public READMEs.
2026-09-30 23:13:03 +02:00

37 lines
918 B
JavaScript
Executable file

'use strict';
var tmp = require('tmp');
// https://github.com/mozilla-b2g/mozilla-profile-builder/issues/2
process.on('SIGINT', function() {});
/**
* Wrapper around common tmp dir creation functionality.
*
* Options:
* - (Boolean) keep: when true profile will not be removed on process close.
*
* @param {Object} options for tmp dir creation.
* @param {Function} callback for tmp dir creation.
*/
function tmpdir(options, callback) {
if (typeof options === 'function') {
callback = options;
options = null;
}
// configuration for temp directory
// https://github.com/raszi/node-tmp#options
var tmpConfig = {};
if (options && options.keep) {
// keep directory for later
tmpConfig.keep = true;
} else {
// discard directory when process closes.
tmpConfig.unsafeCleanup = true;
tmpConfig.keep = false;
}
tmp.dir(tmpConfig, callback);
}
module.exports = tmpdir;