summaryrefslogtreecommitdiff
path: root/cli/tools/standalone.rs
diff options
context:
space:
mode:
Diffstat (limited to 'cli/tools/standalone.rs')
-rw-r--r--cli/tools/standalone.rs44
1 files changed, 28 insertions, 16 deletions
diff --git a/cli/tools/standalone.rs b/cli/tools/standalone.rs
index 4573717a3..f0f53d417 100644
--- a/cli/tools/standalone.rs
+++ b/cli/tools/standalone.rs
@@ -39,11 +39,15 @@ pub async fn compile(
compile_flags: CompileFlags,
) -> Result<(), AnyError> {
let ps = ProcState::build(flags).await?;
- let module_specifier = resolve_url_or_path(&compile_flags.source_file)?;
+ let module_specifier =
+ resolve_url_or_path(&compile_flags.source_file, ps.options.initial_cwd())?;
let deno_dir = &ps.dir;
- let output_path =
- resolve_compile_executable_output_path(&compile_flags).await?;
+ let output_path = resolve_compile_executable_output_path(
+ &compile_flags,
+ ps.options.initial_cwd(),
+ )
+ .await?;
let graph = Arc::try_unwrap(
create_graph_and_maybe_check(module_specifier.clone(), &ps).await?,
@@ -282,8 +286,10 @@ async fn write_standalone_binary(
async fn resolve_compile_executable_output_path(
compile_flags: &CompileFlags,
+ current_dir: &Path,
) -> Result<PathBuf, AnyError> {
- let module_specifier = resolve_url_or_path(&compile_flags.source_file)?;
+ let module_specifier =
+ resolve_url_or_path(&compile_flags.source_file, current_dir)?;
let mut output = compile_flags.output.clone();
@@ -339,12 +345,15 @@ mod test {
#[tokio::test]
async fn resolve_compile_executable_output_path_target_linux() {
- let path = resolve_compile_executable_output_path(&CompileFlags {
- source_file: "mod.ts".to_string(),
- output: Some(PathBuf::from("./file")),
- args: Vec::new(),
- target: Some("x86_64-unknown-linux-gnu".to_string()),
- })
+ let path = resolve_compile_executable_output_path(
+ &CompileFlags {
+ source_file: "mod.ts".to_string(),
+ output: Some(PathBuf::from("./file")),
+ args: Vec::new(),
+ target: Some("x86_64-unknown-linux-gnu".to_string()),
+ },
+ &std::env::current_dir().unwrap(),
+ )
.await
.unwrap();
@@ -356,12 +365,15 @@ mod test {
#[tokio::test]
async fn resolve_compile_executable_output_path_target_windows() {
- let path = resolve_compile_executable_output_path(&CompileFlags {
- source_file: "mod.ts".to_string(),
- output: Some(PathBuf::from("./file")),
- args: Vec::new(),
- target: Some("x86_64-pc-windows-msvc".to_string()),
- })
+ let path = resolve_compile_executable_output_path(
+ &CompileFlags {
+ source_file: "mod.ts".to_string(),
+ output: Some(PathBuf::from("./file")),
+ args: Vec::new(),
+ target: Some("x86_64-pc-windows-msvc".to_string()),
+ },
+ &std::env::current_dir().unwrap(),
+ )
.await
.unwrap();
assert_eq!(path.file_name().unwrap(), "file.exe");