Skip to content

Commit

Permalink
more robust pkgdir finder
Browse files Browse the repository at this point in the history
  • Loading branch information
ZacLN committed Nov 12, 2018
1 parent 135cd8a commit 0703ab1
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 1 deletion.
11 changes: 11 additions & 0 deletions scripts/languageserver/pkgdir.jl
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
using Pkg

c = Pkg.Types.Context()
pkglist = [u[1][string(:path)] for (p,u) in c.env.manifest if haskey(u[1], string(:path))]
if isdir(abspath(joinpath(c.env.manifest_file, "..", "..", "..")))
println(joinpath(abspath(joinpath(c.env.manifest_file, "..", "..", "..")), "dev"))
elseif !isempty(pkglist)
println(dirname(pkglist[1]))
else
println(joinpath(homedir(), ".julia", "dev"))
end
4 changes: 3 additions & 1 deletion src/packagepath.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,9 @@ export async function getPkgPath() {
if (juliaPackagePath == null) {
let jlexepath = await juliaexepath.getJuliaExePath();
// TODO: there's got to be a better way to do this.
var res = await exec(`"${jlexepath}" --startup-file=no --history-file=no -e "(using Pkg;println(dirname([u[1][string(:path)] for (p,u) in Pkg.Types.Context().env.manifest if haskey(u[1], string(:path))][1])))"`);
let scriptpath = join(g_context.extensionPath, "scripts", "languageserver", "pkgdir.jl");
// var res = await exec(`"${jlexepath}" --startup-file=no --history-file=no -e "(using Pkg;println(dirname([u[1][string(:path)] for (p,u) in Pkg.Types.Context().env.manifest if haskey(u[1], string(:path))][1])))"`);
var res = await exec(`"${jlexepath}" --startup-file=no --history-file=no ${scriptpath}`);
juliaPackagePath = res.stdout.trim();
}
return juliaPackagePath;
Expand Down

0 comments on commit 0703ab1

Please sign in to comment.