Skip to content

Commit

Permalink
fix: support hashbang (closes #18)
Browse files Browse the repository at this point in the history
  • Loading branch information
pi0 committed Mar 3, 2021
1 parent 9014df5 commit 6a1f816
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 1 deletion.
8 changes: 7 additions & 1 deletion src/jiti.ts
Original file line number Diff line number Diff line change
Expand Up @@ -133,12 +133,18 @@ export default function createJITI (_filename: string = process.cwd(), opts: JIT
}

function transform (filename: string, source: string, transformOptions: any) {
return getCache(filename, source, () => opts.transform!({
let transfortmed = getCache(filename, source, () => opts.transform!({
source,
filename,
legacy: opts.legacy,
...transformOptions
}))

if (transfortmed.startsWith('#!')) {
transfortmed = '// ' + transfortmed
}

return transfortmed
}

function jiti (id: string) {
Expand Down
4 changes: 4 additions & 0 deletions test/fixtures/hashbang/index.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
#!/usr/bin/env node
// in the Script Goal
'use strict'
console.log(1)

0 comments on commit 6a1f816

Please sign in to comment.