forked from bhollister179/Backtest.jl
-
Notifications
You must be signed in to change notification settings - Fork 0
/
resolve.jl
61 lines (55 loc) · 1.8 KB
/
resolve.jl
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
using Pkg: Pkg
function recurse_projects(
f, path="."; io=stdout, top=true, exclude=("test", "docs", "deps", "user"), kwargs...
)
path = realpath(path)
@sync for subpath in readdir(path)
fullpath = joinpath(path, subpath)
if endswith(fullpath, "Project.toml")
@async f(path, fullpath; io, kwargs...)
elseif isdir(fullpath)
if !startswith(fullpath, ".") && all((!endswith(fullpath, e) for e in exclude))
recurse_projects(f, fullpath; io, top=false, kwargs...)
end
end
end
top && Pkg.activate(pwd())
end
function _update_project(path, fullpath; precomp, inst, doupdate, io=stdout)
projpath = dirname(joinpath(path, fullpath))
Pkg.activate(projpath; io)
Pkg.resolve(; io)
doupdate && begin
Pkg.offline(false)
Pkg.update()
Pkg.offline(true)
end
precomp && Pkg.precompile(; io)
inst && Pkg.instantiate(; io)
end
function update_projects(path="."; io=stdout, doupdate=false, inst=false, precomp=false)
recurse_projects(_update_project, path; io, doupdate, inst, precomp)
end
function _project_name!(path, fullpath; io, projects)
projpath = dirname(joinpath(path, fullpath))
Pkg.activate(projpath; io)
name = Pkg.project().name
isnothing(name) || push!(projects, name)
end
function projects_name(path="."; io=stdout)
projects = Set{String}()
recurse_projects(_project_name!, path; io, projects)
projects
end
function purge_compilecache(path="."; io=stdout)
names = projects_name(path; io)
compiled = joinpath(
homedir(), ".julia", "compiled", "v$(VERSION.major).$(VERSION.minor)"
)
for name in names
pkg_path = joinpath(compiled, name)
if isdir(pkg_path)
rm(pkg_path; recursive=true)
end
end
end