Skip to content

Commit

Permalink
Document directories.bin
Browse files Browse the repository at this point in the history
  • Loading branch information
ehmicky committed Nov 27, 2022
1 parent f160acf commit ab0b48f
Show file tree
Hide file tree
Showing 3 changed files with 23 additions and 5 deletions.
8 changes: 8 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -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
Expand Down
9 changes: 6 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
11 changes: 9 additions & 2 deletions src/main.d.ts
Original file line number Diff line number Diff line change
@@ -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
Expand All @@ -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
Expand All @@ -29,7 +34,9 @@ export function getBinPath(options?: BinaryOptions): Promise<string | undefined>

/**
* 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
Expand Down

0 comments on commit ab0b48f

Please sign in to comment.