File tree 2 files changed +34
-4
lines changed 2 files changed +34
-4
lines changed Original file line number Diff line number Diff line change @@ -69,10 +69,18 @@ function relative_project_path(project_file::String, path::String)
69
69
end
70
70
71
71
function projname (project_file:: String )
72
- p = Base. TOML. Parser ()
73
- Base. TOML. reinit! (p, read (project_file, String); filepath= project_file)
74
- proj = Base. TOML. parse (p)
75
- name = get (proj, " name" , nothing )
72
+ if isfile (project_file)
73
+ name = try
74
+ p = Base. TOML. Parser ()
75
+ Base. TOML. reinit! (p, read (project_file, String); filepath= project_file)
76
+ proj = Base. TOML. parse (p)
77
+ get (proj, " name" , nothing )
78
+ catch
79
+ nothing
80
+ end
81
+ else
82
+ name = nothing
83
+ end
76
84
if name === nothing
77
85
name = basename (dirname (project_file))
78
86
end
Original file line number Diff line number Diff line change @@ -1778,3 +1778,25 @@ end
1778
1778
@test_broken isempty (undoc)
1779
1779
@test undoc == [:AbstractREPL , :BasicREPL , :LineEditREPL , :StreamREPL ]
1780
1780
end
1781
+
1782
+ @testset " Dummy Pkg prompt" begin
1783
+ # do this in an empty depot to test default for new users
1784
+ withenv (" JULIA_DEPOT_PATH" => mktempdir (), " JULIA_LOAD_PATH" => nothing ) do
1785
+ prompt = readchomp (` $(Base. julia_cmd ()[1 ]) --startup-file=no -e "using REPL; print(REPL.Pkg_promptf())"` )
1786
+ @test prompt == " (@v$(VERSION . major) .$(VERSION . minor) ) pkg> "
1787
+ end
1788
+
1789
+ get_prompt (proj:: String ) = readchomp (` $(Base. julia_cmd ()[1 ]) --startup-file=no $(proj) -e "using REPL; print(REPL.Pkg_promptf())"` )
1790
+
1791
+ @test get_prompt (" --project=$(pkgdir (REPL)) " ) == " (REPL) pkg> "
1792
+
1793
+ tdir = mkpath (joinpath (mktempdir (), " foo" ))
1794
+ @test get_prompt (" --project=$tdir " ) == " (foo) pkg> "
1795
+
1796
+ proj_file = joinpath (tdir, " Project.toml" )
1797
+ touch (proj_file) # make a bad Project.toml
1798
+ @test get_prompt (" --project=$proj_file " ) == " (foo) pkg> "
1799
+
1800
+ write (proj_file, " name = \" Bar\"\n " )
1801
+ @test get_prompt (" --project=$proj_file " ) == " (Bar) pkg> "
1802
+ end
You can’t perform that action at this time.
0 commit comments