Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/cap32/babel-plugin-shebang
Replace or prepend shebang
https://github.com/cap32/babel-plugin-shebang
babel babel-plugin bin cli comment env hashbang node replace replace-comment shebang string unix
Last synced: about 2 months ago
JSON representation
Replace or prepend shebang
- Host: GitHub
- URL: https://github.com/cap32/babel-plugin-shebang
- Owner: Cap32
- License: mit
- Created: 2017-06-09T04:33:55.000Z (over 7 years ago)
- Default Branch: master
- Last Pushed: 2022-12-09T08:16:34.000Z (about 2 years ago)
- Last Synced: 2024-11-17T04:53:10.755Z (2 months ago)
- Topics: babel, babel-plugin, bin, cli, comment, env, hashbang, node, replace, replace-comment, shebang, string, unix
- Language: JavaScript
- Homepage:
- Size: 221 KB
- Stars: 4
- Watchers: 3
- Forks: 0
- Open Issues: 12
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# babel-plugin-shebang
[![Build Status](https://travis-ci.org/Cap32/babel-plugin-shebang.svg?branch=master)](https://travis-ci.org/Cap32/babel-plugin-shebang) [![CircleCI](https://circleci.com/gh/Cap32/babel-plugin-shebang.svg?style=shield)](https://circleci.com/gh/Cap32/babel-plugin-shebang)
[![Coverage Status](https://coveralls.io/repos/github/Cap32/babel-plugin-shebang/badge.svg?branch=master)](https://coveralls.io/github/Cap32/babel-plugin-shebang?branch=master)
[![License](https://img.shields.io/badge/license-MIT_License-brightgreen.svg?style=flat)](https://github.com/Cap32/babel-plugin-shebang/blob/master/LICENSE.md)Replace or prepend [shebang]().
Useful to write `#!/usr/bin/env ./node_modules/.bin/babel-node` modules in development env, and compile to `#!/usr/bin/env node` in production env.
## Installation
```sh
$ npm install babel-plugin-shebang
```## Example
**.babelrc**
```json
{
"plugins": ["shebang"]
}
```**input**
```js
#!/usr/bin/env ./node_modules/.bin/babel-node
console.log("awesome");
```**output**
```js
#!/usr/bin/env node
console.log("awesome");
```## Usage
### Via `.babelrc` (Recommended)
**.babelrc**
```json
{
"plugins": [
[
"shebang",
{
"replacement": "#!/usr/bin/env node",
"force": false
}
]
]
}
```### Options
- `replacement` (String): Defaults to `#!/usr/bin/env node`
- `force` (Boolean): Force prepend shebang. Defaults to `false`### Via CLI
```sh
$ babel --plugins shebang script.js
```### Via Node API
```javascript
require("babel-core").transform("code", {
plugins: ["shebang"]
});
```## License
MIT