summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorBartek IwaƄczuk <biwanczuk@gmail.com>2019-06-30 19:32:24 +0200
committerRyan Dahl <ry@tinyclouds.org>2019-06-30 13:32:24 -0400
commit9d18f97327e94ecf6fd0ae7b75a88abfeac07d7e (patch)
treed2583dd1d7c6da9e59a503dd7c3317cd2c6f7de6
parent1068b4848c4d6d9a444d2d2bca5f25d822c42ff5 (diff)
fix: normalize Deno.execPath (#2598)
-rw-r--r--cli/ops.rs7
-rw-r--r--tools/target_test.py5
2 files changed, 10 insertions, 2 deletions
diff --git a/cli/ops.rs b/cli/ops.rs
index bf4016366..0664d8077 100644
--- a/cli/ops.rs
+++ b/cli/ops.rs
@@ -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)]
@@ -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);
diff --git a/tools/target_test.py b/tools/target_test.py
index 98eb4a0eb..58c5d43c7 100644
--- a/tools/target_test.py
+++ b/tools/target_test.py
@@ -55,8 +55,11 @@ class TestTarget(DenoTestCase):
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)