# <%=name%> for npm

This package allows you to install <%=name%> binaries via npm. It automatically detects your platform and installs the correct <%=name%> binary, making it easier to manage and lock version dependencies. This package is part of the [Gobot](https://github.com/benallfree/gobot) registry.

## Usage

### Run the Latest Version of <%=name%>

You can run the latest version of <%=name%> directly using `npx` (for npm) or `bunx` (for Bun):

```bash
npx gobot-<%=slug%> --version
bunx gobot-<%=slug%> --version
```

### Globally Install the Latest Version

To install the latest version globally on your system:

```bash
npm install -g gobot-<%=slug%>
<%=binaryName%> --version
```

### Install as a Dependency

To install the latest version as a dependency in your project:

```bash
bun add gobot-<%=slug%>@<%=version%> --trust
```

Then, and a way to run it as a `package.json` script:

```json
// package.json
"scripts": {
    "<%=binaryName%>": "<%=binaryName%>"
}
```

Now try running it:

```bash
bun run <%=binaryName%> --version
```

> **Note**: The `--trust` flag is required for Bun but not for other package managers. It allows the `postinstall` script to execute, installing the underlying binary.

### Lock to a Specific Version

If you want to lock to a specific version of the <%=name%> binary:

```bash
bun add gobot-<%=slug%>@<%=version%> --trust
```

### Lock to a Minor Version

To lock to a specific minor version, allowing updates to patch versions but not to the major or minor version:

```json
// package.json
"dependencies": {
    "<%=binaryName%>": "^<%=version%>"
}
```

### Update to the Latest Version Globally

To update to the latest version:

```bash
npm i -g <%=packageName%>@latest
<%=binaryName%> --version
```

### Update to the Latest Version in Your Project

To update to the latest version of the <%=name%> binary and the proxy package:

```bash
bun update gobot-<%=slug%> --latest --trust
bun run <%=binaryName%> --version
```

### API

You can also programmatically interact with the <%=name%> binary in your Node.js application using the following API:

```ts
import { binPath } from 'gobot-<%=slug%>'
import { spawn } from 'child_process'

spawn(binPath, [], { stdio: 'inherit' })
```

This example shows how to use the `binPath` from the package to spawn a child process that runs the <%=name%> binary.
