Skip to content

Commit

Permalink
Support autoinstall prompt
Browse files Browse the repository at this point in the history
  • Loading branch information
LilithHafner committed Apr 10, 2024
1 parent be024fd commit 31a92d6
Showing 1 changed file with 14 additions and 0 deletions.
14 changes: 14 additions & 0 deletions src/BasicAutoloads.jl
Original file line number Diff line number Diff line change
Expand Up @@ -55,13 +55,27 @@ function (al::_Autoload)(@nospecialize(expr))
target in al.already_ran && return expr
push!(al.already_ran, target)
try
try_autoinstall(target)
Main.eval(target)
catch err
@info "Failed to run `$target`" exception=err
end
end
expr
end
function try_autoinstall(expr::Expr)
REPL = Base.loaded_modules[Base.PkgId(Base.UUID("3fa0cd96-eef1-5676-8a61-b3b8758bbffb"), "REPL")]
isdefined(REPL, :install_packages_hooks) || return
expr.head in (:using, :import) || return
for arg in expr.args
arg isa Expr && arg.head == :. && length(arg.args) == 1 || continue
mod = only(arg.args)
mod isa Symbol && Base.identify_package(String(mod)) === nothing || continue
for f in REPL.install_packages_hooks
Base.invokelatest(f, [mod]) && break
end
end
end

function _register_ast_transform(ast_transform)
if isdefined(Base, :active_repl_backend)
Expand Down

2 comments on commit 31a92d6

@LilithHafner
Copy link
Owner Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@JuliaRegistrator register()

@JuliaRegistrator
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Registration pull request updated: JuliaRegistries/General/104643

Tip: Release Notes

Did you know you can add release notes too? Just add markdown formatted text underneath the comment after the text
"Release notes:" and it will be added to the registry PR, and if TagBot is installed it will also be added to the
release that TagBot creates. i.e.

@JuliaRegistrator register

Release notes:

## Breaking changes

- blah

To add them here just re-invoke and the PR will be updated.

Tagging

After the above pull request is merged, it is recommended that a tag is created on this repository for the registered package version.

This will be done automatically if the Julia TagBot GitHub Action is installed, or can be done manually through the github interface, or via:

git tag -a v1.0.0 -m "<description of version>" 31a92d646f96a150bcbb0484530e486e8e133572
git push origin v1.0.0

Please sign in to comment.