Js shebang (#2830)

* add shebang to outputted node file
after `chmod`ing the file, it can be run directly
ie `./build/exec/test` rather than `node ./build/exec/test``

* update CHANGELOG.md

* [ linter ]

* [ linter ] again...
This commit is contained in:
Zoe Stafford 2022-12-22 14:56:44 +00:00 committed by GitHub
parent 45fc038300
commit 217271a623
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 10 additions and 1 deletions

View File

@ -27,6 +27,10 @@
* Non-recursive top-level constants are compiled to eagerly evaluated
constants in Chez Scheme.
#### Node.js
* Generated JavaScript files now include a shebang when using the Node.js backend
### Compiler changes
* If `IAlternative` expression with `FirstSuccess` rule fails to typecheck,

View File

@ -31,7 +31,12 @@ compileToNode :
Ref Ctxt Defs ->
Ref Syn SyntaxInfo ->
ClosedTerm -> Core String
compileToNode c s tm = compileToES c s Node tm ["node", "javascript"]
compileToNode c s tm = do
js <- compileToES c s Node tm ["node", "javascript"]
pure $ shebang ++ js
where
shebang : String
shebang = "#!/usr/bin/env node\n"
||| Node implementation of the `compileExpr` interface.
compileExpr :