Skip to content

Commit

Permalink
fix: add shebang for cli entries
Browse files Browse the repository at this point in the history
Fixes #9
  • Loading branch information
Julien-R44 committed Jan 21, 2023
1 parent 87ce4de commit 95fcee8
Show file tree
Hide file tree
Showing 3 changed files with 563 additions and 710 deletions.
14 changes: 14 additions & 0 deletions build.config.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import { defineBuildConfig } from 'unbuild'
import { readFileSync, writeFileSync } from 'fs'

export default defineBuildConfig({
entries: ['src/index', 'src/cli'],
Expand All @@ -8,4 +9,17 @@ export default defineBuildConfig({
rollup: {
emitCJS: true,
},
hooks: {
'build:done': () => {
/**
* Prepend shebang to cli entries since unbuild doesn't seem to support it
*/
const cliEntries = ['dist/cli.mjs', 'dist/cli.cjs']

for (const entry of cliEntries) {
const content = `#!/usr/bin/env node \n${readFileSync(entry, 'utf-8')}`
writeFileSync(entry, content)
}
},
},
})
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,7 @@
"ts-node": "^10.9.1",
"tsx": "^3.12.2",
"typescript": "^4.9.4",
"unbuild": "^0.8.9"
"unbuild": "^1.1.1"
},
"eslintConfig": {
"extends": [
Expand Down
Loading

0 comments on commit 95fcee8

Please sign in to comment.