putout
Version:
🐊 Pluggable and configurable code transformer with built-in ESLint, Babel and support of js, jsx, typescript, flow, markdown, yaml and json
25 lines (18 loc) • 449 B
JavaScript
export const mergeShebang = (shebang, source) => {
if (!shebang)
return source;
return `${shebang}\n${source}`;
};
export const 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`,
];
};