Socket
Socket
Sign inDemoInstall

configstore

Package Overview
Dependencies
12
Maintainers
9
Versions
34
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

Comparing version 5.0.1 to 6.0.0

38

index.js

@@ -1,17 +0,15 @@

'use strict';
const path = require('path');
const os = require('os');
const fs = require('graceful-fs');
const makeDir = require('make-dir');
const xdgBasedir = require('xdg-basedir');
const writeFileAtomic = require('write-file-atomic');
const dotProp = require('dot-prop');
const uniqueString = require('unique-string');
import path from 'path';
import os from 'os';
import fs from 'graceful-fs';
import {xdgConfig} from 'xdg-basedir';
import writeFileAtomic from 'write-file-atomic';
import dotProp from 'dot-prop';
import uniqueString from 'unique-string';
const configDirectory = xdgBasedir.config || path.join(os.tmpdir(), uniqueString());
const configDirectory = xdgConfig || path.join(os.tmpdir(), uniqueString());
const permissionError = 'You don\'t have access to this file.';
const makeDirOptions = {mode: 0o0700};
const mkdirOptions = {mode: 0o0700, recursive: true};
const writeFileOptions = {mode: 0o0600};
class Configstore {
export default class Configstore {
constructor(id, defaults, options = {}) {

@@ -22,3 +20,3 @@ const pathPrefix = options.globalConfigPath ?

this.path = options.configPath || path.join(configDirectory, pathPrefix);
this._path = options.configPath || path.join(configDirectory, pathPrefix);

@@ -35,3 +33,3 @@ if (defaults) {

try {
return JSON.parse(fs.readFileSync(this.path, 'utf8'));
return JSON.parse(fs.readFileSync(this._path, 'utf8'));
} catch (error) {

@@ -50,3 +48,3 @@ // Create directory if it doesn't exist

if (error.name === 'SyntaxError') {
writeFileAtomic.sync(this.path, '', writeFileOptions);
writeFileAtomic.sync(this._path, '', writeFileOptions);
return {};

@@ -62,5 +60,5 @@ }

// Make sure the folder exists as it could have been deleted in the meantime
makeDir.sync(path.dirname(this.path), makeDirOptions);
fs.mkdirSync(path.dirname(this._path), mkdirOptions);
writeFileAtomic.sync(this.path, JSON.stringify(value, undefined, '\t'), writeFileOptions);
writeFileAtomic.sync(this._path, JSON.stringify(value, undefined, '\t'), writeFileOptions);
} catch (error) {

@@ -111,4 +109,6 @@ // Improve the message of permission errors

}
get path() {
return this._path;
}
}
module.exports = Configstore;
{
"name": "configstore",
"version": "5.0.1",
"version": "6.0.0",
"description": "Easily load and save config without having to think about where and how",
"license": "BSD-2-Clause",
"repository": "yeoman/configstore",
"funding": "https://github.com/yeoman/configstore?sponsor=1",
"author": {
"name": "Sindre Sorhus",
"email": "sindresorhus@gmail.com",
"url": "sindresorhus.com"
"url": "https://sindresorhus.com"
},
"type": "module",
"exports": "./index.js",
"engines": {
"node": ">=8"
"node": ">=12"
},

@@ -35,13 +38,15 @@ "scripts": {

"dependencies": {
"dot-prop": "^5.2.0",
"graceful-fs": "^4.1.2",
"make-dir": "^3.0.0",
"unique-string": "^2.0.0",
"write-file-atomic": "^3.0.0",
"xdg-basedir": "^4.0.0"
"dot-prop": "^6.0.1",
"graceful-fs": "^4.2.6",
"unique-string": "^3.0.0",
"write-file-atomic": "^3.0.3",
"xdg-basedir": "^5.0.1"
},
"devDependencies": {
"ava": "^2.1.0",
"xo": "^0.24.0"
"ava": "^3.15.0",
"xo": "^0.38.2"
},
"ava": {
"serial": true
}
}

@@ -1,12 +0,11 @@

# configstore [![Build Status](https://travis-ci.org/yeoman/configstore.svg?branch=master)](https://travis-ci.org/yeoman/configstore)
# configstore
> Easily load and persist config without having to think about where and how
The 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`.\
Example: `~/.config/configstore/some-id.json`
*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.*
*If you need this for Electron, check out [`electron-store`](https://github.com/sindresorhus/electron-store) instead.*\
*And check out [`conf`](https://github.com/sindresorhus/conf) for a more modern version of `configstore`.*
## Install

@@ -18,10 +17,10 @@

## Usage
```js
const Configstore = require('configstore');
const packageJson = require('./package.json');
import Configstore from 'configstore';
// Create a Configstore instance
const packageJson = JSON.parse(fs.readFileSync('./package.json', 'utf8'));
// Create a Configstore instance.
const config = new Configstore(packageJson.name, {foo: 'bar'});

@@ -36,3 +35,3 @@

// Use dot-notation to access nested properties
// Use dot-notation to access nested properties.
config.set('bar.baz', true);

@@ -47,3 +46,2 @@ console.log(config.get('bar'));

## API

@@ -73,3 +71,3 @@

Type: `boolean`<br>
Type: `boolean`\
Default: `false`

@@ -81,3 +79,3 @@

Type: `string`<br>
Type: `string`\
Default: Automatic

@@ -135,3 +133,2 @@

---

@@ -138,0 +135,0 @@

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