1.0.0 • Published 8 years ago

replace-shebang v1.0.0

Weekly downloads
5
License
ISC
Repository
github
Last release
8 years ago

replace-shebang Build Status

Replaces a shebang (eg. #!/bin/sh) by a string using string.replace

Install

$ npm install --save replace-shebang

Usage

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');