mirror of
https://github.com/denoland/deno.git
synced 2024-12-24 16:19:12 -05:00
fix(ext/node): json encode binary command name (#18596)
Fixes https://github.com/denoland/deno/issues/18588
This commit is contained in:
parent
36e8c8dfd7
commit
a7e25b8126
5 changed files with 28 additions and 1 deletions
|
@ -689,6 +689,13 @@ itest!(deno_run_bin_esm {
|
||||||
http_server: true,
|
http_server: true,
|
||||||
});
|
});
|
||||||
|
|
||||||
|
itest!(deno_run_bin_special_chars {
|
||||||
|
args: "run -A --quiet npm:@denotest/special-chars-in-bin-name/\\foo\" this is a test",
|
||||||
|
output: "npm/deno_run_special_chars_in_bin_name.out",
|
||||||
|
envs: env_vars_for_npm_tests(),
|
||||||
|
http_server: true,
|
||||||
|
});
|
||||||
|
|
||||||
itest!(deno_run_bin_no_ext {
|
itest!(deno_run_bin_no_ext {
|
||||||
args: "run -A --quiet npm:@denotest/bin/cli-no-ext this is a test",
|
args: "run -A --quiet npm:@denotest/bin/cli-no-ext this is a test",
|
||||||
output: "npm/deno_run_no_ext.out",
|
output: "npm/deno_run_no_ext.out",
|
||||||
|
|
4
cli/tests/testdata/npm/deno_run_special_chars_in_bin_name.out
vendored
Normal file
4
cli/tests/testdata/npm/deno_run_special_chars_in_bin_name.out
vendored
Normal file
|
@ -0,0 +1,4 @@
|
||||||
|
this
|
||||||
|
is
|
||||||
|
a
|
||||||
|
test
|
5
cli/tests/testdata/npm/registry/@denotest/special-chars-in-bin-name/1.0.0/main.mjs
vendored
Normal file
5
cli/tests/testdata/npm/registry/@denotest/special-chars-in-bin-name/1.0.0/main.mjs
vendored
Normal file
|
@ -0,0 +1,5 @@
|
||||||
|
import process from "node:process";
|
||||||
|
|
||||||
|
for (const arg of process.argv.slice(2)) {
|
||||||
|
console.log(arg);
|
||||||
|
}
|
10
cli/tests/testdata/npm/registry/@denotest/special-chars-in-bin-name/1.0.0/package.json
vendored
Normal file
10
cli/tests/testdata/npm/registry/@denotest/special-chars-in-bin-name/1.0.0/package.json
vendored
Normal file
|
@ -0,0 +1,10 @@
|
||||||
|
{
|
||||||
|
"name": "@denotest/special-chars-in-bin-name",
|
||||||
|
"version": "1.0.0",
|
||||||
|
"type": "module",
|
||||||
|
"main": "main.mjs",
|
||||||
|
"bin": {
|
||||||
|
"\\foo\"": "main.mjs"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
|
@ -3,6 +3,7 @@
|
||||||
use deno_core::error::AnyError;
|
use deno_core::error::AnyError;
|
||||||
use deno_core::located_script_name;
|
use deno_core::located_script_name;
|
||||||
use deno_core::op;
|
use deno_core::op;
|
||||||
|
use deno_core::serde_json;
|
||||||
use deno_core::JsRuntime;
|
use deno_core::JsRuntime;
|
||||||
use once_cell::sync::Lazy;
|
use once_cell::sync::Lazy;
|
||||||
use std::collections::HashSet;
|
use std::collections::HashSet;
|
||||||
|
@ -430,7 +431,7 @@ pub fn initialize_runtime(
|
||||||
maybe_binary_command_name: Option<String>,
|
maybe_binary_command_name: Option<String>,
|
||||||
) -> Result<(), AnyError> {
|
) -> Result<(), AnyError> {
|
||||||
let argv0 = if let Some(binary_command_name) = maybe_binary_command_name {
|
let argv0 = if let Some(binary_command_name) = maybe_binary_command_name {
|
||||||
format!("\"{}\"", binary_command_name)
|
serde_json::to_string(binary_command_name.as_str())?
|
||||||
} else {
|
} else {
|
||||||
"undefined".to_string()
|
"undefined".to_string()
|
||||||
};
|
};
|
||||||
|
|
Loading…
Reference in a new issue