Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/saintedlama/replace-shebang
Replaces the shebang by some string or nothing
https://github.com/saintedlama/replace-shebang
regex shebang
Last synced: about 2 months ago
JSON representation
Replaces the shebang by some string or nothing
- Host: GitHub
- URL: https://github.com/saintedlama/replace-shebang
- Owner: saintedlama
- Created: 2016-04-04T10:30:21.000Z (over 8 years ago)
- Default Branch: master
- Last Pushed: 2017-09-25T09:23:06.000Z (over 7 years ago)
- Last Synced: 2024-10-12T12:25:41.067Z (3 months ago)
- Topics: regex, shebang
- Language: JavaScript
- Size: 5.86 KB
- Stars: 0
- Watchers: 2
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# replace-shebang [![Build Status](https://travis-ci.org/saintedlama/replace-shebang.svg?branch=master)](https://travis-ci.org/saintedlama/replace-shebang)
> Replaces a [shebang](https://en.wikipedia.org/wiki/Shebang_(Unix)) *(eg. `#!/bin/sh`)* by a string using string.replace
## Install
```
$ npm install --save replace-shebang
```## Usage
```js
const fs = require('fs');
const replaceShebang = require('replace-shebang');const str = fs.readFileSync('bin', 'utf8');
//=> #!/usr/bin/env node
//=> console.log('unicorns');// string replacement
replaceShebang(str, '// shebang');
//=> // shebang
//=> console.log('unicorns');// function to replace the shebang
replaceShebang(str, shebang => '// ' + shebang);
//=> // #!/usr/bin/env node
//=> console.log('unicorns');// stripping shebangs
replaceShebang(str);
//=>
//=> console.log('unicorns');
```