firefox-profile
Advanced tools
Comparing version 4.3.2 to 4.4.0
@@ -0,1 +1,5 @@ | ||
# 4.4.0 | ||
- bug fix: return after invoking callback ([web-ext issue](https://github.com/mozilla/web-ext/issues/2826#issuecomment-1739150954)) | ||
# 4.3.2 | ||
@@ -2,0 +6,0 @@ |
'use strict'; | ||
var os = require('os'), | ||
fs = require('fs'), | ||
path = require('path'), | ||
var os = require('os'), | ||
fs = require('fs'), | ||
path = require('path'), | ||
ini = require('ini'); | ||
ini = require('ini'); | ||
function locateUserDirectory(platform) { | ||
@@ -14,3 +12,6 @@ var userDir; | ||
case 'darwin': | ||
userDir = path.join(process.env.HOME, '/Library/Application Support/Firefox'); | ||
userDir = path.join( | ||
process.env.HOME, | ||
'/Library/Application Support/Firefox' | ||
); | ||
break; | ||
@@ -45,3 +46,2 @@ case 'linux': | ||
/** | ||
@@ -53,16 +53,25 @@ * Reads profiles info and stores it in this.profiles. | ||
*/ | ||
ProfileFinder.prototype.readProfiles = function(cb) { | ||
if (this.hasReadProfiles) { cb(null, this.profiles); } | ||
ProfileFinder.prototype.readProfiles = function (cb) { | ||
if (this.hasReadProfiles) { | ||
cb(null, this.profiles); | ||
} | ||
var self = this; | ||
fs.readFile(path.join(this.directory, 'profiles.ini'), {encoding: 'utf8'}, function(err, data) { | ||
if (err) { cb(err); } | ||
Object.entries(ini.parse(data)).forEach(function ([key, value]) { | ||
if (typeof key === 'string' && key.match(/^Profile/)) { | ||
self.profiles.push(value); | ||
fs.readFile( | ||
path.join(this.directory, 'profiles.ini'), | ||
{ encoding: 'utf8' }, | ||
function (err, data) { | ||
if (err) { | ||
cb(err); | ||
return; | ||
} | ||
}); | ||
self.hasReadProfiles = true; | ||
cb(null, self.profiles); | ||
}); | ||
Object.entries(ini.parse(data)).forEach(function ([key, value]) { | ||
if (typeof key === 'string' && key.match(/^Profile/)) { | ||
self.profiles.push(value); | ||
} | ||
}); | ||
self.hasReadProfiles = true; | ||
cb(null, self.profiles); | ||
} | ||
); | ||
}; | ||
@@ -77,17 +86,20 @@ | ||
*/ | ||
ProfileFinder.prototype.getPath = function(name, cb) { | ||
ProfileFinder.prototype.getPath = function (name, cb) { | ||
var self = this; | ||
function findInProfiles(name, cb) { | ||
var pathFound, | ||
found = self.profiles.find(function(profile) { | ||
return profile.Name === name; | ||
}); | ||
found = self.profiles.find(function (profile) { | ||
return profile.Name === name; | ||
}); | ||
if (found) { | ||
pathFound = found.IsRelative ? path.join(self.directory, found.Path) : found.Path; | ||
pathFound = found.IsRelative | ||
? path.join(self.directory, found.Path) | ||
: found.Path; | ||
} | ||
cb && cb(found ? null : new Error('cannot find profile ' + name), pathFound); | ||
cb && | ||
cb(found ? null : new Error('cannot find profile ' + name), pathFound); | ||
return pathFound; | ||
} | ||
if (!this.hasReadProfiles) { | ||
this.readProfiles(function() { | ||
this.readProfiles(function () { | ||
findInProfiles(name, cb); | ||
@@ -94,0 +106,0 @@ }); |
{ | ||
"name": "firefox-profile", | ||
"version": "4.3.2", | ||
"version": "4.4.0", | ||
"description": "firefox profile for selenium WebDriverJs, admc/wd or any other node selenium driver that supports capabilities", | ||
@@ -5,0 +5,0 @@ "main": "lib/firefox_profile", |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
46897
976