+8
-3
@@ -35,3 +35,6 @@ 'use strict'; | ||
| } | ||
| const value = destr(match[2].trim()); | ||
| const value = destr( | ||
| match[2].trim() | ||
| /* val */ | ||
| ); | ||
| if (key.endsWith("[]")) { | ||
@@ -62,3 +65,5 @@ const nkey = key.slice(0, Math.max(0, key.length - 2)); | ||
| function serialize(config) { | ||
| return Object.entries(flat.flatten(config)).map(([key, value]) => `${key}=${typeof value === "string" ? value : JSON.stringify(value)}`).join("\n"); | ||
| return Object.entries(flat.flatten(config)).map( | ||
| ([key, value]) => `${key}=${typeof value === "string" ? value : JSON.stringify(value)}` | ||
| ).join("\n"); | ||
| } | ||
@@ -81,3 +86,3 @@ function write(config, options) { | ||
| } | ||
| const newConfig = defu(config, read(options)); | ||
| const newConfig = defu.defu(config, read(options)); | ||
| write(newConfig, options); | ||
@@ -84,0 +89,0 @@ return newConfig; |
+1
-1
@@ -1,2 +0,2 @@ | ||
| declare type RC = Record<string, any>; | ||
| type RC = Record<string, any>; | ||
| interface RCOptions { | ||
@@ -3,0 +3,0 @@ name?: string; |
+8
-3
@@ -6,3 +6,3 @@ import { existsSync, readFileSync, writeFileSync } from 'node:fs'; | ||
| import flat from 'flat'; | ||
| import defu from 'defu'; | ||
| import { defu } from 'defu'; | ||
@@ -34,3 +34,6 @@ const RE_KEY_VAL = /^\s*([^\s=]+)\s*=\s*(.*)?\s*$/; | ||
| } | ||
| const value = destr(match[2].trim()); | ||
| const value = destr( | ||
| match[2].trim() | ||
| /* val */ | ||
| ); | ||
| if (key.endsWith("[]")) { | ||
@@ -61,3 +64,5 @@ const nkey = key.slice(0, Math.max(0, key.length - 2)); | ||
| function serialize(config) { | ||
| return Object.entries(flat.flatten(config)).map(([key, value]) => `${key}=${typeof value === "string" ? value : JSON.stringify(value)}`).join("\n"); | ||
| return Object.entries(flat.flatten(config)).map( | ||
| ([key, value]) => `${key}=${typeof value === "string" ? value : JSON.stringify(value)}` | ||
| ).join("\n"); | ||
| } | ||
@@ -64,0 +69,0 @@ function write(config, options) { |
+23
-21
| { | ||
| "name": "rc9", | ||
| "version": "2.0.0", | ||
| "version": "2.0.1", | ||
| "description": "Read/Write config couldn't be easier!", | ||
@@ -11,3 +11,4 @@ "repository": "unjs/rc9", | ||
| "require": "./dist/index.cjs", | ||
| "import": "./dist/index.mjs" | ||
| "import": "./dist/index.mjs", | ||
| "types": "./dist/index.d.ts" | ||
| } | ||
@@ -20,12 +21,5 @@ }, | ||
| ], | ||
| "scripts": { | ||
| "build": "unbuild", | ||
| "dev": "vitest", | ||
| "lint": "eslint --ext .ts .", | ||
| "release": "pnpm test && pnpm build && standard-version && git push --follow-tags && pnpm publish", | ||
| "test": "pnpm lint && vitest run --coverage" | ||
| }, | ||
| "dependencies": { | ||
| "defu": "^6.1.1", | ||
| "destr": "^1.2.1", | ||
| "defu": "^6.1.2", | ||
| "destr": "^1.2.2", | ||
| "flat": "^5.0.2" | ||
@@ -35,12 +29,20 @@ }, | ||
| "@types/flat": "^5.0.2", | ||
| "@types/node": "^18.11.9", | ||
| "@vitest/coverage-c8": "^0.25.2", | ||
| "eslint": "^8.27.0", | ||
| "eslint-config-unjs": "^0.0.2", | ||
| "standard-version": "^9.5.0", | ||
| "typescript": "^4.8.4", | ||
| "unbuild": "^0.9.4", | ||
| "vitest": "^0.25.2" | ||
| "@types/node": "^18.11.18", | ||
| "@vitest/coverage-c8": "^0.28.1", | ||
| "changelogen": "^0.4.1", | ||
| "eslint": "^8.32.0", | ||
| "eslint-config-unjs": "^0.1.0", | ||
| "prettier": "^2.8.3", | ||
| "typescript": "^4.9.4", | ||
| "unbuild": "^1.1.1", | ||
| "vitest": "^0.28.1" | ||
| }, | ||
| "packageManager": "pnpm@7.16.0" | ||
| } | ||
| "packageManager": "pnpm@7.25.0", | ||
| "scripts": { | ||
| "build": "unbuild", | ||
| "dev": "vitest", | ||
| "lint": "eslint --ext .ts . && prettier -c src test", | ||
| "release": "pnpm test && pnpm build && changelogen --release && pnpm publish && git push --follow-tags", | ||
| "test": "pnpm lint && vitest run --coverage" | ||
| } | ||
| } |
-72
| # Changelog | ||
| All notable changes to this project will be documented in this file. See [standard-version](https://github.com/conventional-changelog/standard-version) for commit guidelines. | ||
| ## [2.0.0](https://github.com/unjs/rc9/compare/v1.2.3...v2.0.0) (2022-11-15) | ||
| ### [1.2.3](https://github.com/unjs/rc9/compare/v1.2.2...v1.2.3) (2022-11-15) | ||
| ### [1.2.2](https://github.com/unjs/rc9/compare/v1.2.1...v1.2.2) (2022-04-07) | ||
| ### Bug Fixes | ||
| * avoid optional chaining for node 12.x compatibility ([a4349ab](https://github.com/unjs/rc9/commit/a4349ab85606e71b65e6a4df70dc889d26223efd)) | ||
| ### [1.2.1](https://github.com/unjs/rc9/compare/v1.2.0...v1.2.1) (2022-04-07) | ||
| ### Bug Fixes | ||
| * use `XDG_CONFIG_HOME` for `writeUser` and `updateUser` ([5c1f7a9](https://github.com/unjs/rc9/commit/5c1f7a9873302b9ae04bf2eb979a315caaa4ce96)) | ||
| ## [1.2.0](https://github.com/unjs/rc9/compare/v1.1.0...v1.2.0) (2020-11-25) | ||
| ### Features | ||
| * support `XDG_CONFIG_HOME` (closes [#1](https://github.com/unjs/rc9/issues/1)) ([2792d9b](https://github.com/unjs/rc9/commit/2792d9b93d16771425a56a0166e3d2a3cac3fa34)) | ||
| ## [1.1.0](https://github.com/unjs/rc9/compare/v1.0.0...v1.1.0) (2020-11-09) | ||
| ### Features | ||
| * support array push syntax ([6d1ff0d](https://github.com/unjs/rc9/commit/6d1ff0dff0dfb4fa94b3687f91a8b629c020ed54)) | ||
| ## [1.0.0](https://github.com/unjs/rc9/compare/v0.0.7...v1.0.0) (2020-06-16) | ||
| ### [0.0.7](https://github.com/unjs/rc9/compare/v0.0.6...v0.0.7) (2020-05-28) | ||
| ### Bug Fixes | ||
| * set `sideEffects` field in package.json to allow tree-shaking ([c8fc9cc](https://github.com/unjs/rc9/commit/c8fc9ccc8eeffe70f5cf6d8ae832989c9ce3bdb4)) | ||
| ### [0.0.6](https://github.com/unjs/rc9/compare/v0.0.5...v0.0.6) (2020-05-28) | ||
| ### [0.0.5](https://github.com/unjs/rc9/compare/v0.0.4...v0.0.5) (2020-05-28) | ||
| ### [0.0.4](https://github.com/unjs/rc9/compare/v0.0.3...v0.0.4) (2020-05-28) | ||
| ### [0.0.3](https://github.com/unjs/rc9/compare/v0.0.2...v0.0.3) (2020-05-28) | ||
| ### Features | ||
| * update() and improvements ([69539be](https://github.com/unjs/rc9/commit/69539bed862cf5659971329d2007e78d97bcd2a4)) | ||
| ### [0.0.2](https://github.com/unjs/rc9/compare/v0.0.1...v0.0.2) (2020-05-27) | ||
| ### Features | ||
| * support directly passing name as options ([e493cdf](https://github.com/unjs/rc9/commit/e493cdf8fda7bda4eb2b95148485d8a008feff4c)) | ||
| ### Bug Fixes | ||
| * allow more characters for key ([9557009](https://github.com/unjs/rc9/commit/955700996ff0b9f3c34135adb42146d718df83a7)) | ||
| * pass encoding to writeFileSync ([59c937a](https://github.com/unjs/rc9/commit/59c937a9a434e28d9e083db66b552383b61a975f)) | ||
| ### 0.0.1 (2020-05-27) |
Environment variable access
Supply chain riskPackage accesses environment variables, which may be a sign of credential stuffing or data theft.
Found 1 instance in 1 package
Environment variable access
Supply chain riskPackage accesses environment variables, which may be a sign of credential stuffing or data theft.
Found 1 instance in 1 package
207
5.08%12255
-16.54%10
11.11%6
-14.29%Updated
Updated