File tree Expand file tree Collapse file tree 1 file changed +14
-0
lines changed
Expand file tree Collapse file tree 1 file changed +14
-0
lines changed Original file line number Diff line number Diff line change @@ -55,13 +55,27 @@ function (al::_Autoload)(@nospecialize(expr))
5555 target in al. already_ran && return expr
5656 push! (al. already_ran, target)
5757 try
58+ try_autoinstall (target)
5859 Main. eval (target)
5960 catch err
6061 @info " Failed to run `$target `" exception= err
6162 end
6263 end
6364 expr
6465end
66+ function try_autoinstall (expr:: Expr )
67+ REPL = Base. loaded_modules[Base. PkgId (Base. UUID (" 3fa0cd96-eef1-5676-8a61-b3b8758bbffb" ), " REPL" )]
68+ isdefined (REPL, :install_packages_hooks ) || return
69+ expr. head in (:using , :import ) || return
70+ for arg in expr. args
71+ arg isa Expr && arg. head == :. && length (arg. args) == 1 || continue
72+ mod = only (arg. args)
73+ mod isa Symbol && Base. identify_package (String (mod)) === nothing || continue
74+ for f in REPL. install_packages_hooks
75+ Base. invokelatest (f, [mod]) && break
76+ end
77+ end
78+ end
6579
6680function _register_ast_transform (ast_transform)
6781 if isdefined (Base, :active_repl_backend )
You can’t perform that action at this time.
0 commit comments