putout
Version:
🐊 Pluggable and configurable code transformer with built-in ESLint, Babel and support of js, jsx, typescript, flow, markdown, yaml and json
27 lines (19 loc) • 468 B
JavaScript
;
module.exports.mergeShebang = (shebang, source) => {
if (!shebang)
return source;
return `${shebang}\n${source}`;
};
module.exports.cutShebang = (source) => {
if (source.indexOf('#'))
return [source, ''];
const lines = source.split('\n');
const result = lines
.slice(1)
.join('\n');
const [shebang] = lines;
return [
result,
`${shebang}\n`,
];
};