Skip to content

Commit

Permalink
Require Node.js 18
Browse files Browse the repository at this point in the history
Minor tweaks

Meta tweaks
  • Loading branch information
sindresorhus committed Nov 5, 2023
1 parent 8179ed3 commit f7000a1
Show file tree
Hide file tree
Showing 8 changed files with 33 additions and 21 deletions.
4 changes: 4 additions & 0 deletions .github/funding.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
github: sindresorhus
open_collective: sindresorhus
tidelift: npm/pkg-conf
custom: https://sindresorhus.com/donate
3 changes: 3 additions & 0 deletions .github/security.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
# Security Policy

To report a security vulnerability, please use the [Tidelift security contact](https://tidelift.com/security). Tidelift will coordinate the fix and disclosure.
7 changes: 4 additions & 3 deletions .github/workflows/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,10 +10,11 @@ jobs:
fail-fast: false
matrix:
node-version:
- 16
- 20
- 18
steps:
- uses: actions/checkout@v2
- uses: actions/setup-node@v2
- uses: actions/checkout@v4
- uses: actions/setup-node@v4
with:
node-version: ${{ matrix.node-version }}
- run: npm install
Expand Down
8 changes: 4 additions & 4 deletions index.d.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
export type Config = Record<string, unknown>;

export interface Options<ConfigType extends Config> {
export type Options<ConfigType extends Config> = {
/**
The directory to start looking up for a `package.json` file.
Expand Down Expand Up @@ -32,10 +32,10 @@ export interface Options<ConfigType extends Config> {
```
*/
readonly skipOnFalse?: boolean;
}
};

/**
It [walks up](https://github.com/sindresorhus/find-up) parent directories until a `package.json` can be found, reads it, and returns the user specified namespace or an empty object if not found.
It [walks up](https://github.com/sindresorhus/find-up-simple) parent directories until a `package.json` can be found, reads it, and returns the user specified namespace or an empty object if not found.
@param namespace - The `package.json` namespace you want.
@returns A `Promise` for the config.
Expand Down Expand Up @@ -64,7 +64,7 @@ export function packageConfig<ConfigType extends Config = Config>(
): Promise<ConfigType & Config>;

/**
It [walks up](https://github.com/sindresorhus/find-up) parent directories until a `package.json` can be found, reads it, and returns the user specified namespace or an empty object if not found.
It [walks up](https://github.com/sindresorhus/find-up-simple) parent directories until a `package.json` can be found, reads it, and returns the user specified namespace or an empty object if not found.
@param namespace - The `package.json` namespace you want.
@returns Returns the config.
Expand Down
4 changes: 2 additions & 2 deletions index.js
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
import path from 'node:path';
import {findUp, findUpSync} from 'find-up';
import {findUp, findUpSync} from 'find-up-simple';
import {loadJsonFile, loadJsonFileSync} from 'load-json-file';

const filePaths = new WeakMap();
const findNextCwd = pkgPath => path.resolve(path.dirname(pkgPath), '..');
const findNextCwd = packagePath => path.resolve(path.dirname(packagePath), '..');

const addFilePath = (object, filePath) => {
filePaths.set(object, filePath);
Expand Down
2 changes: 1 addition & 1 deletion index.test-d.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import {expectType, expectAssignable} from 'tsd';
import {packageConfig, packageConfigSync, packageJsonPath, Config} from './index.js';
import {packageConfig, packageConfigSync, packageJsonPath, type Config} from './index.js';

await packageConfig('name', {cwd: '.'});
await packageConfig('name', {skipOnFalse: true});
Expand Down
18 changes: 11 additions & 7 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -11,9 +11,13 @@
"url": "https://sindresorhus.com"
},
"type": "module",
"exports": "./index.js",
"exports": {
"types": "./index.d.ts",
"default": "./index.js"
},
"sideEffects": false,
"engines": {
"node": "^12.20.0 || ^14.13.1 || >=16.0.0"
"node": ">=18"
},
"scripts": {
"test": "xo && ava && tsd"
Expand All @@ -38,13 +42,13 @@
"namespaced"
],
"dependencies": {
"find-up": "^6.0.0",
"load-json-file": "^7.0.0"
"find-up-simple": "^1.0.0",
"load-json-file": "^7.0.1"
},
"devDependencies": {
"ava": "^3.15.0",
"tsd": "^0.17.0",
"xo": "^0.44.0"
"ava": "^5.3.1",
"tsd": "^0.29.0",
"xo": "^0.56.0"
},
"fixture": {
"foo": true
Expand Down
8 changes: 4 additions & 4 deletions readme.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,8 @@ Having tool specific config in package.json reduces the amount of metafiles in y

## Install

```
$ npm install pkg-conf
```sh
npm install pkg-conf
```

## Usage
Expand All @@ -33,7 +33,7 @@ console.log(config.rainbow);

## API

It [walks up](https://github.com/sindresorhus/find-up) parent directories until a `package.json` can be found, reads it, and returns the user specified namespace or an empty object if not found.
It [walks up](https://github.com/sindresorhus/find-up-simple) parent directories until a `package.json` can be found, reads it, and returns the user specified namespace or an empty object if not found.

### packageConfig(namespace, options?)

Expand Down Expand Up @@ -93,6 +93,6 @@ Returns the file path to the package.json file or `undefined` if not found.

## Related

- [read-pkg-up](https://github.com/sindresorhus/read-pkg-up) - Read the closest package.json file
- [read-package-up](https://github.com/sindresorhus/read-package-up) - Read the closest package.json file
- [read-pkg](https://github.com/sindresorhus/read-pkg) - Read a package.json file
- [find-up](https://github.com/sindresorhus/find-up) - Find a file by walking up parent directories

0 comments on commit f7000a1

Please sign in to comment.