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.0 to 3.0.1

CHANGELOG.md

54

lib/settings.js

@@ -18,3 +18,3 @@ 'use strict';

/**
* Local reference to the Electron app.
* Called when the settings file is changed or renamed.
*

@@ -24,21 +24,5 @@ * @type {Object}

*/
this._app = electron.app || electron.remote.app;
this._handleSettingsChange = this._onSettingsChange.bind(this);
/**
* The path to the user data folder for the current app.
*
* @type {string}
* @private
*/
this._userDataPath = this._app.getPath('userData');
/**
* The absolute path to the settings file.
*
* @type {string}
* @private
*/
this._settingsPath = path.join(this._userDataPath, 'Settings');
/**
* The FSWatcher instance. This will watch if the settings file and

@@ -52,10 +36,18 @@ * notify key path observers.

this._fsWatcher = null;
}
/**
* Called when the settings file is changed or renamed.
*
* @type {Object}
* @private
*/
this._handleSettingsChange = this._onSettingsChange.bind(this);
/**
* Gets the absolute path to the user settings file. This is done
* dynamically instead of being cached during instantiation because
* it is possible to change the user data path programatically.
*
* @returns {string}
* @private
*/
_getSettingsPath() {
const app = electron.app || electron.remote.app;
const userDataPath = app.getPath('userData');
const settingsFilePath = path.join(userDataPath, 'Settings');
return settingsFilePath;
}

@@ -72,4 +64,6 @@

if (!this._fsWatcher) {
const settingsFilePath = this._getSettingsPath();
try {
this._fsWatcher = fs.watch(this._settingsPath, this._handleSettingsChange);
this._fsWatcher = fs.watch(settingsFilePath, this._handleSettingsChange);
} catch(err) {

@@ -89,4 +83,6 @@ // File may not exist yet or possible user permissions error.

_writeSettings(obj={}, opts={}) {
const settingsFilePath = this._getSettingsPath();
try {
fs.outputJsonSync(this._settingsPath, obj, {
fs.outputJsonSync(settingsFilePath, obj, {
spaces: opts.prettify ? 2 : 0

@@ -108,4 +104,6 @@ });

_readSettings() {
const settingsFilePath = this._getSettingsPath();
try {
return fs.readJsonSync(this._settingsPath);
return fs.readJsonSync(settingsFilePath);
} catch(err) {

@@ -112,0 +110,0 @@ this._writeSettings();

{
"name": "electron-settings",
"version": "3.0.0",
"version": "3.0.1",
"description": "A simple persistent user settings manager for Electron.",

@@ -5,0 +5,0 @@ "main": "index.js",

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