Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

electron-settings

Package Overview
Dependencies
Maintainers
1
Versions
47
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

electron-settings - npm Package Compare versions

Comparing version 3.0.14 to 3.1.0

86

lib/settings.js

@@ -40,3 +40,3 @@ /**

*/
const settingsFileName = 'Settings';
const defaultSettingsFileName = 'Settings';

@@ -48,3 +48,3 @@ /**

*/
const settingsFilePath = path.join(userDataPath, settingsFileName);
const defaultSettingsFilePath = path.join(userDataPath, defaultSettingsFileName);

@@ -63,3 +63,3 @@ /**

/**
* The absolute path to the settings file on the disk.
* The absolute path to the default settings file on the disk.
*

@@ -69,5 +69,14 @@ * @type {string}

*/
this._settingsFilePath = settingsFilePath;
this._defaultSettingsFilePath = defaultSettingsFilePath;
/**
* The absolute path to the custom settings file on the disk.
*
* @type {string}
* @default null
* @private
*/
this._customSettingsFilePath = null;
/**
* The FSWatcher instance. This will watch if the settings file and

@@ -92,2 +101,36 @@ * notify key path observers.

/**
* Returns the settings file path.
*
* @returns {string}
* @private
*/
_getSettingsFilePath() {
return this._customSettingsFilePath ?
this._customSettingsFilePath :
this._defaultSettingsFilePath;
}
/**
* Sets a custom settings file path.
*
* @param {string} filePath
* @private
*/
_setSettingsFilePath(filePath) {
this._customSettingsFilePath = filePath;
// Reset FSWatcher.
this._unwatchSettings(true);
}
/**
* Clears the custom settings file path.
*
* @private
*/
_clearSettingsFilePath() {
this._setSettingsFilePath(null);
}
/**
* Watches the settings file for changes using the native `FSWatcher`

@@ -102,3 +145,3 @@ * class in case the settings file is changed outside of

try {
this._fsWatcher = fs.watch(this._settingsFilePath, this._handleSettingsFileChange);
this._fsWatcher = fs.watch(this._getSettingsFilePath(), this._handleSettingsFileChange);
} catch (err) {

@@ -136,7 +179,9 @@ // File may not exist yet or the user may not have permission to

_ensureSettings() {
const settingsFilePath = this._getSettingsFilePath();
try {
jsonfile.readFileSync(this._settingsFilePath);
jsonfile.readFileSync(settingsFilePath);
} catch (err) {
try {
jsonfile.writeFileSync(this._settingsFilePath, {});
jsonfile.writeFileSync(settingsFilePath, {});
} catch (err) {

@@ -165,3 +210,3 @@ // Cannot read or write file. The user may not have permission to

jsonfile.writeFileSync(this._settingsFilePath, obj, { spaces });
jsonfile.writeFileSync(this._getSettingsFilePath(), obj, { spaces });
} catch (err) {

@@ -184,3 +229,3 @@ // Could not write the file. The user may not have permission to

try {
return jsonfile.readFileSync(this._settingsFilePath);
return jsonfile.readFileSync(this._getSettingsFilePath());
} catch (err) {

@@ -457,2 +502,23 @@ // Could not read the file. The user may not have permission to

/**
* Sets a custom settings file path.
*
* @param {string} filePath
* @public
*/
setPath(filePath) {
assert.strictEqual(typeof filePath, 'string', 'First parameter must be a string');
this._setSettingsFilePath(filePath);
}
/**
* Clears the custom settings file path.
*
* @public
*/
clearPath() {
this._clearSettingsFilePath();
}
/**
* Returns the absolute path to where the settings file is or will be stored.

@@ -464,3 +530,3 @@ *

file() {
return this._settingsFilePath;
return this._getSettingsFilePath();
}

@@ -467,0 +533,0 @@ }

17

package.json
{
"name": "electron-settings",
"version": "3.0.14",
"version": "3.1.0",
"description": "A simple persistent user settings framework for Electron.",

@@ -13,3 +13,3 @@ "main": "index.js",

"type": "git",
"url": "https://github.com/nathanbuchar/electron-settings"
"url": "https://github.com/nathanbuchar/electron-settings.git"
},

@@ -39,12 +39,13 @@ "author": "Nathan Buchar <hello@nathanbuchar.com>",

"clone": "^2.1.1",
"jsonfile": "^2.4.0"
"jsonfile": "^3.0.0"
},
"devDependencies": {
"electron": "^1.6.2",
"electron": "^1.7.2",
"electron-mocha": "^3.4.0",
"eslint": "^3.18.0",
"eslint-config-airbnb-base": "^11.1.2",
"eslint-plugin-import": "^2.2.0",
"mocha": "^3.2.0"
"eslint": "^3.19.0",
"eslint-config-airbnb-base": "^11.2.0",
"eslint-plugin-import": "^2.3.0",
"mocha": "^3.4.2",
"randomstring": "^1.1.5"
}
}
SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc