tsup/src/plugins/shebang.ts
EGOIST 524470c49b
feat: experimental plugin system (#486)
Co-authored-by: EGOIST <0x142857@gmail.com>
Co-authored-by: 木杉 <zhmushan@qq.com>
2021-12-10 15:44:27 +08:00

16 lines
308 B
TypeScript

import { Plugin } from '../plugin'
export const shebang = (): Plugin => {
return {
name: 'shebang',
renderChunk(_, info) {
if (info.type === 'chunk' && /\.(cjs|js|mjs)$/.test(info.path)) {
if (info.code.startsWith('#!')) {
info.mode = 0o755
}
}
},
}
}