Skip to content

Commit

Permalink
fix: normalize Deno.execPath (#2598)
Browse files Browse the repository at this point in the history
  • Loading branch information
bartlomieju authored and ry committed Jun 30, 2019
1 parent 1068b48 commit 9d18f97
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 2 deletions.
7 changes: 6 additions & 1 deletion cli/ops.rs
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,7 @@ use tokio::net::TcpListener;
use tokio::net::TcpStream;
use tokio_process::CommandExt;
use tokio_threadpool;
use url::Url;
use utime;

#[cfg(unix)]
Expand Down Expand Up @@ -345,8 +346,12 @@ fn op_start(
let cwd_off =
builder.create_string(deno_fs::normalize_path(cwd_path.as_ref()).as_ref());

let current_exe = std::env::current_exe().unwrap();
// Now apply URL parser to current exe to get fully resolved path, otherwise we might get
// `./` and `../` bits in `exec_path`
let exe_url = Url::from_file_path(current_exe).unwrap();
let exec_path =
builder.create_string(std::env::current_exe().unwrap().to_str().unwrap());
builder.create_string(exe_url.to_file_path().unwrap().to_str().unwrap());

let v8_version = version::v8();
let v8_version_off = builder.create_string(v8_version);
Expand Down
5 changes: 4 additions & 1 deletion tools/target_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -55,8 +55,11 @@ def test_no_color(self):
assert result.out.strip() == "noColor false"

def test_exec_path(self):
cmd = [self.deno_exe, "run", "tests/exec_path.ts"]
cmd = [self.deno_exe, "run", "--allow-run", "tests/exec_path.ts"]
result = run_output(cmd, quiet=True)
print "exec_path", result.code
print result.out
print result.err
assert self.deno_exe in result.out.strip()
self.assertEqual(result.code, 0)

Expand Down

0 comments on commit 9d18f97

Please sign in to comment.