-
Notifications
You must be signed in to change notification settings - Fork 231
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
A way to get the directory of the source file. #1369
Comments
awawawawawa.
|
@iacore That doesn't give me a path to the source file. |
@amano-kenji You can pass what comes back from # scratch.janet
(import spork/path)
(print (path/abspath (dyn *current-file*))) $ janet scratch.janet If you're opposed to using spork, you can look at the implementation of spork/path for how to roll your own (spork/path is implemented in pure Janet). |
I read spork/path.janet
I think it just adds the current working directory to I assume that janet doesn't let you get the source directory, yet. jpm doesn't install a lua script into /usr/bin, either. I want to execute a lua script and get its standard output from my janet code. |
The following idea does not address the issue but I think one might say it can address:
Within one's project directory, create the lua script named Then, in one's
Executing Now To increase the probability of one's script being executed, it might help to choose a name for it that is unlikely to be used by other folks. Update: I looked at this comment and following its advice, discovered (defn declare-bin
"Declare a generic file to be installed as an executable."
[&keys {:main main}]
(install-rule main (dyn:binpath))) That might be a better choice than (defn declare-binscript
``Declare a janet file to be installed as an executable script. Creates
a shim on windows. If hardcode is true, will insert code into the script
such that it will run correctly even when JANET_PATH is changed. if auto-shebang
is truthy, will also automatically insert a correct shebang line.
`` It seems |
|
Sometimes, I want to execute an executable on a path relative to the janet source file that executes it.
For now, that doesn't seem possible.
The text was updated successfully, but these errors were encountered: