From ab0b48f0b8e05310c9d3e25859f40b87277a2f81 Mon Sep 17 00:00:00 2001 From: ehmicky Date: Sun, 27 Nov 2022 21:31:43 +0100 Subject: [PATCH] Document directories.bin --- CHANGELOG.md | 8 ++++++++ README.md | 9 ++++++--- src/main.d.ts | 11 +++++++++-- 3 files changed, 23 insertions(+), 5 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 4196bdb..2bdde17 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,3 +1,11 @@ +# 8.0.0 + +## Breaking changes + +- Add support for the + [`directories.bin` field](https://docs.npmjs.com/cli/v9/configuring-npm/package-json#directoriesbin) + in `package.json` + # 7.3.0 ## Features diff --git a/README.md b/README.md index 48eb046..4b3f982 100644 --- a/README.md +++ b/README.md @@ -10,14 +10,17 @@ [![Medium](https://img.shields.io/badge/-Medium-808080.svg?logo=medium&colorA=404040)](https://medium.com/@ehmicky) Get the current package's binary path (using the `package.json` -[`bin` field](https://docs.npmjs.com/files/package.json#bin)). +[`bin`](https://docs.npmjs.com/files/package.json#bin) or +[`directories.bin`](https://docs.npmjs.com/cli/v9/configuring-npm/package-json#directoriesbin) +field). This is useful when testing a package's binary. Using `get-bin-path` (as opposed to hard-coding the path to the binary): -- validates that the `package.json` `bin` field is correctly setup. +- validates that the `package.json` `bin` or `directories.bin` field is + correctly setup - decouples the binary path from the tests, which allows moving the file without - rewriting the tests. + rewriting the tests # Examples diff --git a/src/main.d.ts b/src/main.d.ts index 5a1a03a..38a1cac 100644 --- a/src/main.d.ts +++ b/src/main.d.ts @@ -1,3 +1,6 @@ +/** + * `get-bin-path` options + */ export type BinaryOptions = Partial<{ /** * Name of the binary. Only needs to be specified when the package exports @@ -18,7 +21,9 @@ export type BinaryOptions = Partial<{ /** * Get the current package's binary path (using the `package.json` - * [`bin` field](https://docs.npmjs.com/files/package.json#bin)). + * [`bin`](https://docs.npmjs.com/files/package.json#bin) or + * [`directories.bin`](https://docs.npmjs.com/cli/v9/configuring-npm/package-json#directoriesbin) + * field). * * @example * ```js @@ -29,7 +34,9 @@ export function getBinPath(options?: BinaryOptions): Promise /** * Get the current package's binary path (using the `package.json` - * [`bin` field](https://docs.npmjs.com/files/package.json#bin)). + * [`bin`](https://docs.npmjs.com/files/package.json#bin) or + * [`directories.bin`](https://docs.npmjs.com/cli/v9/configuring-npm/package-json#directoriesbin) + * field). * * @example * ```js