1
0
mirror of https://github.com/janet-lang/janet synced 2024-12-27 00:40:26 +00:00

Add --auto-shebang option to jpm.

This commit is contained in:
Calvin Rose 2021-03-11 18:35:12 -06:00
parent 78f6b6a507
commit c8a13ce475
2 changed files with 6 additions and 1 deletions

3
jpm
View File

@ -1087,6 +1087,7 @@ int main(int argc, const char **argv) {
`` ``
[&keys {:main main :hardcode-syspath hardcode :auto-shebang auto-shebang}] [&keys {:main main :hardcode-syspath hardcode :auto-shebang auto-shebang}]
(def binpath (dyn :binpath JANET_BINPATH)) (def binpath (dyn :binpath JANET_BINPATH))
(def auto-shebang (or auto-shebang (dyn :auto-shebang)))
(if (or auto-shebang hardcode) (if (or auto-shebang hardcode)
(let [syspath (dyn :modpath JANET_MODPATH)] (let [syspath (dyn :modpath JANET_MODPATH)]
(def parts (peg/match path-splitter main)) (def parts (peg/match path-splitter main))
@ -1100,7 +1101,7 @@ int main(int argc, const char **argv) {
(def second-line (string/format "(put root-env :syspath %v)\n" syspath)) (def second-line (string/format "(put root-env :syspath %v)\n" syspath))
(def rest (:read f :all)) (def rest (:read f :all))
(string (if auto-shebang (string (if auto-shebang
(string "#!" JANET_BINPATH "/janet\n")) (string "#!" (dyn :binpath JANET_BINPATH) "/janet\n"))
first-line (if hardcode second-line) rest))) first-line (if hardcode second-line) rest)))
(create-dirs path) (create-dirs path)
(spit path contents) (spit path contents)

4
jpm.1
View File

@ -42,6 +42,10 @@ Prevents jpm from going to network to get dependencies - all dependencies should
Use this flag with the deps and update-pkgs subcommands. This is not a surefire way to prevent a build script from accessing Use this flag with the deps and update-pkgs subcommands. This is not a surefire way to prevent a build script from accessing
the network, for example, a build script that invokes curl will still have network access. the network, for example, a build script that invokes curl will still have network access.
.TP
.BR \-\-auto\-shebang
Prepends installed scripts with a generated shebang line, such that they will use a janet binary located in JANET_BINPATH.
.SH OPTIONS .SH OPTIONS
.TP .TP