# rollup-plugin-shebang-bin

> Richly configurable rollup plugin for preserving or inserting shebang (hashbang) and making scripts executable.

Latest version **0.1.0** (published 2024-12-10) · MIT license · 0 weekly downloads

## Install

```sh
npm install rollup-plugin-shebang-bin
pnpm add rollup-plugin-shebang-bin
yarn add rollup-plugin-shebang-bin
bun add rollup-plugin-shebang-bin
```

## Health

**Score 40/100 (D)** — status: maintenance-mode.

Positive: has types; esm support; no vulnerabilities; high quality score.

Warnings: low downloads; pre 1.0.

Negative: stale; low maintenance score.

## Facts

| | |
|---|---|
| Version | 0.1.0 |
| Published | 2024-12-10 |
| First published | 2022-01-23 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | bundled |
| Module format | ESM + CommonJS |
| Node | >= 14.18 |
| Dependencies | 2 |
| Unpacked size | 16.1 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 3 |
| Author | Ferdinand Prantl |
| Maintainers | prantlf |
| Keywords | rollup, plugin, rollup-plugin, shebang, hashbang, bin, executable |

## Links

- npm: https://www.npmjs.com/package/rollup-plugin-shebang-bin
- Repository: https://github.com/prantlf/rollup-plugin-shebang-bin
- Homepage: http://github.com/prantlf/rollup-plugin-shebang-bin/
- Issues: http://github.com/prantlf/rollup-plugin-shebang-bin/issues
- npm.io page: https://npm.io/package/rollup-plugin-shebang-bin

## Dependencies (2)

- [magic-string](https://npm.io/package/magic-string.md) ^0.30.15
- [@rollup/pluginutils](https://npm.io/package/@rollup/pluginutils.md) ^5.1.3

## Alternatives

- [@gemini-wallet/core](https://npm.io/package/@gemini-wallet/core.md) — 515.6K weekly downloads
- [utility](https://npm.io/package/utility.md) — 416.6K weekly downloads
- [@primno/dpapi](https://npm.io/package/@primno/dpapi.md) — 7.2K weekly downloads
- [pi-readseek](https://npm.io/package/pi-readseek.md) — 3.7K weekly downloads
- [@emilia-protocol/verify](https://npm.io/package/@emilia-protocol/verify.md) — 1.1K weekly downloads

## Recent versions

- 0.1.0 (latest) — 2024-12-10
- 0.0.7 — 2024-08-06
- 0.0.6 — 2023-10-08
- 0.0.5 — 2022-10-30
- 0.0.4 — 2022-06-03
- 0.0.3 — 2022-05-23
- 0.0.2 — 2022-05-10
- 0.0.1 — 2022-01-23

## README

# rollup-plugin-shebang-bin

[![Latest version](https://img.shields.io/npm/v/rollup-plugin-shebang-bin)
 ![Dependency status](https://img.shields.io/librariesio/release/npm/rollup-plugin-shebang-bin)
](https://www.npmjs.com/package/rollup-plugin-shebang-bin)
[![Coverage](https://codecov.io/gh/prantlf/rollup-plugin-shebang-bin/branch/master/graph/badge.svg)](https://codecov.io/gh/prantlf/rollup-plugin-shebang-bin)

Richly configurable [Rollup] plugin for preserving or inserting shebang (hashbang) and making scripts executable.

## Requirements

This plugin requires [Node.js] 14 or newer and [Rollup] 2 or newer.

## Installation

This module can be installed in your project using [NPM], [PNPM] or [Yarn]. Make sure, that you use [Node.js] version 6 or newer.

```sh
npm i -D rollup-plugin-shebang-bin
pnpm i -D rollup-plugin-shebang-bin
yarn add rollup-plugin-shebang-bin
```

## Usage

Create a `rollup.config.js` [configuration file] and import the plugin:

```js
import shebang from 'rollup-plugin-shebang-bin'

export default {
  input: 'src/cli.js',
  output: {
    dir: 'bin',
    format: 'cjs'
  },
  plugins: [shebang()]
}
```

Then call `rollup` either via the [command-line] or [programmatically].

The file `bin/cli.js` will be executable with the following content:

```js
#!/usr/bin/env node

... // content of src/cli.js
```

## Options

The following options can be passed in an object to the plugin function to change the default values.

### `include`

Type: `Array<String>`<br>
Default: ['**/*.js']

[Pattern] to match files which will be processed by the plugin.

### `exclude`

Type: `Array<String>`<br>
Default: []

[Pattern] to match files which will be ignored by the plugin.

### `regexp`

Type: `RegExp`<br>
Default: `/^\s*#!.*\n*/`

The regular expression to match the shebang at the beginning of an input file.

### `shebang`

Type: `String`<br>
Default: `'#!/usr/bin/env node'`

The shebang to insert to the beginning of an output file.

### `separator`

Type: `String`<br>
Default: `'\n\n'`

The whitespace to insert after the shebang to separate if from the rest of an output file.

### `mode`

Type: `Number`<br>
Default: `0o755`

The permissions to apply to an output file. The value will be masked by the process `umask`.

### `insert`

Type: `Boolean`<br>
Default: `true`

If the shebang will be inserted to an output file.

### `preserve`

Type: `Boolean`<br>
Default: `true`

If an existing shebang will be preserved in an output file.

If you set `preserve` to `false` and `insert` to `true`, the existing shebang will be removed and a new one inserted to an output file.

### `executable`

Type: `Boolean`<br>
Default: `true`

If an output file should become executable permissions.

## License

Copyright (C) 2022-2024 Ferdinand Prantl

Licensed under the [MIT License].

[MIT License]: http://en.wikipedia.org/wiki/MIT_License
[Rollup]: https://rollupjs.org/
[Node.js]: https://nodejs.org/
[NPM]: https://www.npmjs.com/
[PNPM]: https://pnpm.io/
[Yarn]: https://yarnpkg.com/
[configuration file]: https://www.rollupjs.org/guide/en/#configuration-files
[command-line]: https://www.rollupjs.org/guide/en/#command-line-reference
[programmatically]: https://www.rollupjs.org/guide/en/#javascript-api
[Pattern]: https://www.linuxjournal.com/content/bash-extended-globbing

---
_Source: https://npm.io/package/rollup-plugin-shebang-bin · Machine-readable twin of the npm.io package page. Health data is recomputed on every publish._
