File tree Expand file tree Collapse file tree 2 files changed +34
-4
lines changed Expand file tree Collapse file tree 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 @@ -1836,3 +1836,25 @@ end
1836
1836
@test_broken isempty (undoc)
1837
1837
@test undoc == [:AbstractREPL , :BasicREPL , :LineEditREPL , :StreamREPL ]
1838
1838
end
1839
+
1840
+ @testset " Dummy Pkg prompt" begin
1841
+ # do this in an empty depot to test default for new users
1842
+ withenv (" JULIA_DEPOT_PATH" => mktempdir (), " JULIA_LOAD_PATH" => nothing ) do
1843
+ prompt = readchomp (` $(Base. julia_cmd ()[1 ]) --startup-file=no -e "using REPL; print(REPL.Pkg_promptf())"` )
1844
+ @test prompt == " (@v$(VERSION . major) .$(VERSION . minor) ) pkg> "
1845
+ end
1846
+
1847
+ get_prompt (proj:: String ) = readchomp (` $(Base. julia_cmd ()[1 ]) --startup-file=no $(proj) -e "using REPL; print(REPL.Pkg_promptf())"` )
1848
+
1849
+ @test get_prompt (" --project=$(pkgdir (REPL)) " ) == " (REPL) pkg> "
1850
+
1851
+ tdir = mkpath (joinpath (mktempdir (), " foo" ))
1852
+ @test get_prompt (" --project=$tdir " ) == " (foo) pkg> "
1853
+
1854
+ proj_file = joinpath (tdir, " Project.toml" )
1855
+ touch (proj_file) # make a bad Project.toml
1856
+ @test get_prompt (" --project=$proj_file " ) == " (foo) pkg> "
1857
+
1858
+ write (proj_file, " name = \" Bar\"\n " )
1859
+ @test get_prompt (" --project=$proj_file " ) == " (Bar) pkg> "
1860
+ end
You can’t perform that action at this time.
0 commit comments