Skip to content

Commit

Permalink
artifact"name" should search the current directory when run from th…
Browse files Browse the repository at this point in the history
…e REPL (#1662)

This enables more interactive usage of `@artifact_str` from the REPL.
  • Loading branch information
staticfloat authored Apr 7, 2020
1 parent 89792a8 commit 46b9179
Showing 1 changed file with 7 additions and 1 deletion.
8 changes: 7 additions & 1 deletion src/Artifacts.jl
Original file line number Diff line number Diff line change
Expand Up @@ -1029,14 +1029,20 @@ end
Macro that is used to automatically ensure an artifact is installed, and return its
location on-disk. Automatically looks the artifact up by name in the project's
`(Julia)Artifacts.toml` file. Throws an error on inability to install the requested artifact.
If run in the REPL, searches for the toml file starting in the current directory, see
`find_artifacts_toml()` for more.
!!! compat "Julia 1.3"
This macro requires at least Julia 1.3.
"""
macro artifact_str(name)
# Load Artifacts.toml at compile time, so that we don't have to use `__source__.file`
# at runtime, which gets stale if the `.ji` file is relocated.
local artifacts_toml = find_artifacts_toml(string(__source__.file))
srcfile = string(__source__.file)
if startswith(srcfile, "REPL[") && !isfile(srcfile)
srcfile = pwd()
end
local artifacts_toml = find_artifacts_toml(srcfile)
if artifacts_toml === nothing
error(string(
"Cannot locate '(Julia)Artifacts.toml' file when attempting to use artifact '",
Expand Down

0 comments on commit 46b9179

Please sign in to comment.