From 61b83f0bb9a4f255e35615cc25e5ea01c973d083 Mon Sep 17 00:00:00 2001 From: Federico Brigante Date: Sat, 13 Jul 2024 09:46:25 +0000 Subject: [PATCH] Update all dependencies --- index.js | 26 ++++++++++++++------------ package.json | 10 +++++----- test.js | 20 ++++++++++---------- 3 files changed, 29 insertions(+), 27 deletions(-) diff --git a/index.js b/index.js index 7f370d9..f36d5b5 100644 --- a/index.js +++ b/index.js @@ -1,9 +1,11 @@ -import path from 'path'; -import os from 'os'; +import path from 'node:path'; +import os from 'node:os'; import fs from 'graceful-fs'; import {xdgConfig} from 'xdg-basedir'; import {writeFileSync} from 'atomically'; -import dotProp from 'dot-prop'; +import { + getProperty, setProperty, hasProperty, deleteProperty, +} from 'dot-prop'; import uniqueString from 'unique-string'; const configDirectory = xdgConfig || path.join(os.tmpdir(), uniqueString()); @@ -13,16 +15,16 @@ const writeFileOptions = {mode: 0o0600}; export default class Configstore { constructor(id, defaults, options = {}) { - const pathPrefix = options.globalConfigPath ? - path.join(id, 'config.json') : - path.join('configstore', `${id}.json`); + const pathPrefix = options.globalConfigPath + ? path.join(id, 'config.json') + : path.join('configstore', `${id}.json`); this._path = options.configPath || path.join(configDirectory, pathPrefix); if (defaults) { this.all = { ...defaults, - ...this.all + ...this.all, }; } } @@ -72,7 +74,7 @@ export default class Configstore { } get(key) { - return dotProp.get(this.all, key); + return getProperty(this.all, key); } set(key, value) { @@ -80,22 +82,22 @@ export default class Configstore { if (arguments.length === 1) { for (const k of Object.keys(key)) { - dotProp.set(config, k, key[k]); + setProperty(config, k, key[k]); } } else { - dotProp.set(config, key, value); + setProperty(config, key, value); } this.all = config; } has(key) { - return dotProp.has(this.all, key); + return hasProperty(this.all, key); } delete(key) { const config = this.all; - dotProp.delete(config, key); + deleteProperty(config, key); this.all = config; } diff --git a/package.json b/package.json index 86d7fc6..1662bf7 100644 --- a/package.json +++ b/package.json @@ -36,14 +36,14 @@ ], "dependencies": { "atomically": "^2.0.3", - "dot-prop": "^6.0.1", - "graceful-fs": "^4.2.6", + "dot-prop": "^9.0.0", + "graceful-fs": "^4.2.11", "unique-string": "^3.0.0", - "xdg-basedir": "^5.0.1" + "xdg-basedir": "^5.1.0" }, "devDependencies": { - "ava": "^3.15.0", - "xo": "^0.38.2" + "ava": "^6.1.3", + "xo": "^0.58.0" }, "ava": { "serial": true diff --git a/test.js b/test.js index 30c2f6a..8fa1297 100644 --- a/test.js +++ b/test.js @@ -1,6 +1,6 @@ -import fs from 'fs'; -import path from 'path'; -import os from 'os'; +import fs from 'node:fs'; +import path from 'node:path'; +import os from 'node:os'; import test from 'ava'; import Configstore from './index.js'; @@ -33,17 +33,17 @@ test('.set() with object and .get()', t => { baz: { boo: 'foo', foo: { - bar: 'baz' - } - } + bar: 'baz', + }, + }, }); t.is(config.get('foo1'), 'bar1'); t.is(config.get('foo2'), 'bar2'); t.deepEqual(config.get('baz'), { boo: 'foo', foo: { - bar: 'baz' - } + bar: 'baz', + }, }); t.is(config.get('baz.boo'), 'foo'); t.deepEqual(config.get('baz.foo'), {bar: 'baz'}); @@ -119,7 +119,7 @@ test('support `configPath` option', t => { const customPath = path.join(os.tmpdir(), 'configstore-custom-path', 'foo.json'); const config = new Configstore('ignored-namespace', {}, { globalConfigPath: true, - configPath: customPath + configPath: customPath, }); t.regex(config.path, /configstore-custom-path(\/|\\)foo.json$/); }); @@ -144,7 +144,7 @@ test('ensure necessary sub-directories are created', t => { const customPath = path.join(fs.mkdtempSync(path.join(os.tmpdir(), 'configstore-recursive-')), 'foo', 'bar', 'baz.json'); const config = new Configstore('ignored-namespace', undefined, { globalConfigPath: true, - configPath: customPath + configPath: customPath, }); t.false(fs.existsSync(config.path)); config.set('foo', 'bar');