replace-shebang
v1.0.0
Published
Replaces the shebang by some string or nothing
Downloads
1
Readme
replace-shebang
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');