Skip to content

Commit c1309f7

Browse files
authored
Catch errors in README generation instead of throwing (#19)
1 parent 1b7d301 commit c1309f7

2 files changed

Lines changed: 22 additions & 16 deletions

File tree

Project.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
name = "ITensorFormatter"
22
uuid = "b6bf39f1-c9d3-4bad-aad8-593d802f65fd"
3-
version = "0.2.12"
3+
version = "0.2.13"
44
authors = ["ITensor developers <support@itensor.org> and contributors"]
55

66
[workspace]

src/generate_readme.jl

Lines changed: 21 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -15,22 +15,28 @@ function generate_readmes!(paths::AbstractVector{<:AbstractString})
1515
end
1616

1717
function generate_readme!(path::AbstractString)
18-
isitensorpkg(path) ||
19-
error("Can't generate README: not an ITensor package directory: `$path`.")
20-
cd(joinpath(path, "docs")) do
21-
julia = Base.julia_cmd()
22-
code = """
23-
using Pkg: Pkg
24-
# Install packages needed for "make_readme.jl".
25-
Pkg.instantiate(; io = devnull)
26-
include("make_readme.jl")
27-
"""
28-
cmd = `$(julia) --project=. --startup-file=no -e "$(code)"`
29-
cmd = setenv(
30-
cmd, "JULIA_LOAD_PATH" => "@:@stdlib", "JULIA_PKG_USE_CLI_GIT" => "true"
31-
)
32-
run(cmd)
18+
if !isitensorpkg(path)
19+
@warn "Can't generate README: not an ITensor package directory: `$path`."
3320
return nothing
3421
end
22+
try
23+
cd(joinpath(path, "docs")) do
24+
julia = Base.julia_cmd()
25+
code = """
26+
using Pkg: Pkg
27+
# Install packages needed for "make_readme.jl".
28+
Pkg.instantiate(; io = devnull)
29+
include("make_readme.jl")
30+
"""
31+
cmd = `$(julia) --project=. --startup-file=no -e "$(code)"`
32+
cmd = setenv(
33+
cmd, "JULIA_LOAD_PATH" => "@:@stdlib", "JULIA_PKG_USE_CLI_GIT" => "true"
34+
)
35+
run(cmd)
36+
return nothing
37+
end
38+
catch e
39+
@warn "Failed to generate README: $e"
40+
end
3541
return nothing
3642
end

0 commit comments

Comments
 (0)