Socket
Socket
Sign inDemoInstall

configstore

Package Overview
Dependencies
13
Maintainers
6
Versions
34
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

Comparing version 4.0.0 to 5.0.0

11

index.js

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

const configDir = xdgBasedir.config || path.join(os.tmpdir(), uniqueString());
const configDirectory = xdgBasedir.config || path.join(os.tmpdir(), uniqueString());
const permissionError = 'You don\'t have access to this file.';

@@ -23,6 +23,9 @@ const makeDirOptions = {mode: 0o0700};

this.path = options.configPath || path.join(configDir, pathPrefix);
this.path = options.configPath || path.join(configDirectory, pathPrefix);
if (defaults) {
this.all = Object.assign({}, defaults, this.all);
this.all = {
...defaults,
...this.all
};
}

@@ -60,3 +63,3 @@ }

writeFileAtomic.sync(this.path, JSON.stringify(value, null, '\t'), writeFileOptions);
writeFileAtomic.sync(this.path, JSON.stringify(value, undefined, '\t'), writeFileOptions);
} catch (error) {

@@ -63,0 +66,0 @@ // Improve the message of permission errors

{
"name": "configstore",
"version": "4.0.0",
"version": "5.0.0",
"description": "Easily load and save config without having to think about where and how",

@@ -13,3 +13,3 @@ "license": "BSD-2-Clause",

"engines": {
"node": ">=6"
"node": ">=8"
},

@@ -26,3 +26,2 @@ "scripts": {

"storage",
"conf",
"configuration",

@@ -38,13 +37,13 @@ "settings",

"dependencies": {
"dot-prop": "^4.1.0",
"dot-prop": "^5.1.0",
"graceful-fs": "^4.1.2",
"make-dir": "^1.0.0",
"unique-string": "^1.0.0",
"write-file-atomic": "^2.0.0",
"xdg-basedir": "^3.0.0"
"make-dir": "^3.0.0",
"unique-string": "^2.0.0",
"write-file-atomic": "^3.0.0",
"xdg-basedir": "^4.0.0"
},
"devDependencies": {
"ava": "*",
"xo": "*"
"ava": "^2.1.0",
"xo": "^0.24.0"
}
}

@@ -5,6 +5,7 @@ # configstore [![Build Status](https://travis-ci.org/yeoman/configstore.svg?branch=master)](https://travis-ci.org/yeoman/configstore)

Config is stored in a JSON file located in `$XDG_CONFIG_HOME` or `~/.config`.<br>
The config is stored in a JSON file located in `$XDG_CONFIG_HOME` or `~/.config`.<br>
Example: `~/.config/configstore/some-id.json`
*If you need this for Electron, check out [`electron-store`](https://github.com/sindresorhus/electron-store) instead.*
*If you need this for Electron, check out [`electron-store`](https://github.com/sindresorhus/electron-store) instead.*<br>
*And check out [`conf`](https://github.com/sindresorhus/conf) for an updated approach to this concept.*

@@ -23,22 +24,21 @@

const Configstore = require('configstore');
const pkg = require('./package.json');
const packageJson = require('./package.json');
// create a Configstore instance with an unique ID e.g.
// Package name and optionally some default values
const conf = new Configstore(pkg.name, {foo: 'bar'});
// Create a Configstore instance
const config = new Configstore(packageJson.name, {foo: 'bar'});
console.log(conf.get('foo'));
console.log(config.get('foo'));
//=> 'bar'
conf.set('awesome', true);
console.log(conf.get('awesome'));
config.set('awesome', true);
console.log(config.get('awesome'));
//=> true
// Use dot-notation to access nested properties
conf.set('bar.baz', true);
console.log(conf.get('bar'));
config.set('bar.baz', true);
console.log(config.get('bar'));
//=> {baz: true}
conf.delete('awesome');
console.log(conf.get('awesome'));
config.delete('awesome');
console.log(config.get('awesome'));
//=> undefined

@@ -50,3 +50,3 @@ ```

### Configstore(packageName, [defaults], [options])
### Configstore(packageName, defaults?, options?)

@@ -63,3 +63,3 @@ Returns a new instance.

Type: `Object`
Type: `object`

@@ -70,2 +70,4 @@ Default config.

Type: `object`
##### globalConfigPath

@@ -128,3 +130,3 @@

```js
conf.all = {
config.all = {
hello: 'world'

@@ -135,5 +137,12 @@ };

## License
---
[BSD license](http://opensource.org/licenses/bsd-license.php)<br>
Copyright Google
<div align="center">
<b>
<a href="https://tidelift.com/subscription/pkg/npm-configstore?utm_source=npm-configstore&utm_medium=referral&utm_campaign=readme">Get professional support for this package with a Tidelift subscription</a>
</b>
<br>
<sub>
Tidelift helps make open source sustainable for maintainers while giving companies<br>assurances about security, maintenance, and licensing for their dependencies.
</sub>
</div>
SocketSocket SOC 2 Logo

Product

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

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc