-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathclean.jl
More file actions
67 lines (56 loc) · 1.94 KB
/
clean.jl
File metadata and controls
67 lines (56 loc) · 1.94 KB
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
62
63
64
65
66
67
"""
clean([distclean=false])
Clean up build/doc/testing artifacts. Restore to clean checkout state
(distclean)
"""
function clean(; distclean=false, _exit=true)
_exists(name) = isfile(name) || isdir(name)
_push!(lst, name) = _exists(name) && push!(lst, name)
function _glob(folder, ending)
if !_exists(folder)
return []
end
[name for name in readdir(folder; join=true) if (name |> endswith(ending))]
end
function _glob_star(folder; except=[])
if !_exists(folder)
return []
end
[
joinpath(folder, name) for
name in readdir(folder) if !(name |> startswith(".") || name ∈ except)
]
end
ROOT = @__DIR__
###########################################################################
CLEAN = String[]
_push!(CLEAN, joinpath(ROOT, "coverage"))
_push!(CLEAN, joinpath(ROOT, "docs", "build"))
append!(CLEAN, _glob(ROOT, ".info"))
append!(CLEAN, _glob(joinpath(ROOT, ".coverage"), ".info"))
###########################################################################
###########################################################################
DISTCLEAN = String[]
_push!(DISTCLEAN, joinpath(ROOT, "docs", "src", "examples"))
_push!(DISTCLEAN, joinpath(ROOT, "docs", "src", "tutorials"))
_push!(DISTCLEAN, joinpath(ROOT, "Manifest.toml"))
###########################################################################
for name in CLEAN
@info "rm $name"
rm(name, force=true, recursive=true)
end
clean_examples(joinpath(ROOT, "examples"))
clean_examples(joinpath(ROOT, "tutorials"))
if distclean
for name in DISTCLEAN
@info "rm $name"
rm(name, force=true, recursive=true)
end
if _exit
@info "Exiting"
exit(0)
end
end
end
include("src/collect_examples.jl")
include("src/clean_examples.jl")