-
Notifications
You must be signed in to change notification settings - Fork 57
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
tools: add source
field (Loc)
#900
Conversation
Missing ReScript bindings here, right? Should add them to the ReScript files. |
ReScript files updated! |
tools/src/tools.ml
Outdated
let findRelativePath ~rootPath ~path = | ||
let open Filename in | ||
let realPath = | ||
match rootPath = "." with | ||
| true -> Sys.getcwd () | ||
| false -> | ||
if is_relative rootPath then concat (Sys.getcwd ()) rootPath else rootPath | ||
in | ||
let rec loop dirPath acc = | ||
match dirname dirPath = realPath with | ||
| true -> basename dirPath :: acc |> String.concat "/" | ||
| false -> ( | ||
match dirPath with | ||
| "/" -> failwith "Failed to find relative path of package" | ||
| "." -> path | ||
| _ -> loop (dirname dirPath) (basename dirPath :: acc)) | ||
in | ||
|
||
loop path [] |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
No built in fn that does this I take it...?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
thank you. Found in Analysis.Files.realpath
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Great! Now we just need to figure out the tests for Windows. Paths being different is obviously expected.
Emit location of type/value/module
In general, you can run the command from anywhere. The
filepath
property is relative to the package root.