Skip to content

Commit

Permalink
Drop uuid and just use native mkdtemp (#122)
Browse files Browse the repository at this point in the history
* Drop `uuid`

* Travis support

* Update package-lock.json
  • Loading branch information
fregante authored Mar 10, 2021
1 parent 5761816 commit 94b7279
Show file tree
Hide file tree
Showing 4 changed files with 2,353 additions and 2,725 deletions.
15 changes: 5 additions & 10 deletions lib/firefox_profile.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@ var os = require('os'),
// third-party
parseString = require('xml2js').parseString,
AdmZip = require('adm-zip'),
uuid = require('uuid'),
Finder = require('./profile_finder');

var config = {
Expand Down Expand Up @@ -151,7 +150,7 @@ function FirefoxProfile(options) {
this.profileDir = opts.destinationDirectory || this._createTempFolder();
} else {
// create copy
var tmpDir = opts.destinationDirectory || this._createTempFolder('-copy');
var tmpDir = opts.destinationDirectory || this._createTempFolder('copy-');
fs.copySync(opts.profileDirectory, tmpDir, {
clobber: true,
filter: isNotLockFile,
Expand Down Expand Up @@ -575,7 +574,7 @@ FirefoxProfile.prototype._installExtension = function (addon, cb) {
self = this;

if (addon.slice(-4) === '.xpi') {
tmpDir = this._createTempFolder(addon.split(path.sep).slice(-1));
tmpDir = this._createTempFolder(addon.split(path.sep).pop());
var zip = new AdmZip(addon);
zip.extractAllTo(tmpDir, true);
xpiFile = addon;
Expand Down Expand Up @@ -713,13 +712,9 @@ FirefoxProfile.prototype._addonDetails = function (addonPath, cb) {
});
};

FirefoxProfile.prototype._createTempFolder = function (suffix) {
suffix = suffix || '';
var folderName = path.resolve(
path.join(os.tmpdir(), uuid.v4() + suffix + path.sep)
);
fs.mkdirSync(folderName);
return folderName;
FirefoxProfile.prototype._createTempFolder = function (prefix) {
// Don't use an empty string for `prefix` or it might not work on some CIs (Travis)
return fs.mkdtempSync(path.resolve(os.tmpdir(), prefix || 'firefox-profile')) + '/';
};

FirefoxProfile.prototype._sanitizePref = function (val) {
Expand Down
Loading

0 comments on commit 94b7279

Please sign in to comment.