1
0
Fork 0
mirror of https://github.com/denoland/deno.git synced 2024-11-21 15:04:11 -05:00

fix(install): should always include --no-config in shim unless --config is specified (#17300)

Closes #17294
This commit is contained in:
David Sherret 2023-01-08 09:03:55 -05:00 committed by GitHub
parent ad82918f56
commit 2be1282be4
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 43 additions and 20 deletions

View file

@ -55,12 +55,12 @@ mod install {
if cfg!(windows) { if cfg!(windows) {
assert_contains!( assert_contains!(
content, content,
r#""run" "--check" "http://localhost:4545/echo.ts""# r#""run" "--check" "--no-config" "http://localhost:4545/echo.ts""#
); );
} else { } else {
assert_contains!( assert_contains!(
content, content,
r#"run --check 'http://localhost:4545/echo.ts'"# r#"run --check --no-config 'http://localhost:4545/echo.ts'"#
); );
} }
@ -121,12 +121,12 @@ mod install {
if cfg!(windows) { if cfg!(windows) {
assert_contains!( assert_contains!(
content, content,
r#""run" "--check" "http://localhost:4545/echo.ts""# r#""run" "--check" "--no-config" "http://localhost:4545/echo.ts""#
); );
} else { } else {
assert_contains!( assert_contains!(
content, content,
r#"run --check 'http://localhost:4545/echo.ts'"# r#"run --check --no-config 'http://localhost:4545/echo.ts'"#
); );
} }
} }

View file

@ -409,6 +409,8 @@ fn resolve_shim_data(
fs::read_to_string(config_path) fs::read_to_string(config_path)
.with_context(|| format!("error reading {}", config_path))?, .with_context(|| format!("error reading {}", config_path))?,
)); ));
} else {
executable_args.push("--no-config".to_string());
} }
if flags.no_lock { if flags.no_lock {
@ -616,11 +618,12 @@ mod tests {
let content = fs::read_to_string(file_path).unwrap(); let content = fs::read_to_string(file_path).unwrap();
if cfg!(windows) { if cfg!(windows) {
assert!(content.contains( assert!(content.contains(
r#""run" "--unstable" "http://localhost:4545/echo_server.ts""# r#""run" "--unstable" "--no-config" "http://localhost:4545/echo_server.ts""#
)); ));
} else { } else {
assert!(content assert!(content.contains(
.contains(r#"run --unstable 'http://localhost:4545/echo_server.ts'"#)); r#"run --unstable --no-config 'http://localhost:4545/echo_server.ts'"#
));
} }
} }
@ -641,7 +644,7 @@ mod tests {
assert_eq!(shim_data.name, "echo_server"); assert_eq!(shim_data.name, "echo_server");
assert_eq!( assert_eq!(
shim_data.args, shim_data.args,
vec!["run", "http://localhost:4545/echo_server.ts",] vec!["run", "--no-config", "http://localhost:4545/echo_server.ts",]
); );
} }
@ -662,7 +665,7 @@ mod tests {
assert_eq!(shim_data.name, "subdir"); assert_eq!(shim_data.name, "subdir");
assert_eq!( assert_eq!(
shim_data.args, shim_data.args,
vec!["run", "http://localhost:4545/subdir/main.ts",] vec!["run", "--no-config", "http://localhost:4545/subdir/main.ts",]
); );
} }
@ -683,7 +686,7 @@ mod tests {
assert_eq!(shim_data.name, "echo_test"); assert_eq!(shim_data.name, "echo_test");
assert_eq!( assert_eq!(
shim_data.args, shim_data.args,
vec!["run", "http://localhost:4545/echo_server.ts",] vec!["run", "--no-config", "http://localhost:4545/echo_server.ts",]
); );
} }
@ -715,6 +718,7 @@ mod tests {
"--allow-read", "--allow-read",
"--allow-net", "--allow-net",
"--quiet", "--quiet",
"--no-config",
"http://localhost:4545/echo_server.ts", "http://localhost:4545/echo_server.ts",
"--foobar", "--foobar",
] ]
@ -740,7 +744,12 @@ mod tests {
assert_eq!( assert_eq!(
shim_data.args, shim_data.args,
vec!["run", "--no-prompt", "http://localhost:4545/echo_server.ts",] vec![
"run",
"--no-prompt",
"--no-config",
"http://localhost:4545/echo_server.ts",
]
); );
} }
@ -763,7 +772,12 @@ mod tests {
assert_eq!( assert_eq!(
shim_data.args, shim_data.args,
vec!["run", "--allow-all", "http://localhost:4545/echo_server.ts",] vec![
"run",
"--allow-all",
"--no-config",
"http://localhost:4545/echo_server.ts",
]
); );
} }
@ -791,6 +805,7 @@ mod tests {
vec![ vec![
"run", "run",
"--allow-all", "--allow-all",
"--no-config",
"--lock", "--lock",
&lock_path.to_string_lossy(), &lock_path.to_string_lossy(),
"npm:cowsay" "npm:cowsay"
@ -819,7 +834,13 @@ mod tests {
assert_eq!( assert_eq!(
shim_data.args, shim_data.args,
vec!["run", "--allow-all", "--no-lock", "npm:cowsay"] vec![
"run",
"--allow-all",
"--no-config",
"--no-lock",
"npm:cowsay"
]
); );
assert_eq!(shim_data.extra_files, vec![]); assert_eq!(shim_data.extra_files, vec![]);
} }
@ -981,9 +1002,9 @@ mod tests {
if cfg!(windows) { if cfg!(windows) {
// TODO: see comment above this test // TODO: see comment above this test
} else { } else {
assert!( assert!(content.contains(
content.contains(r#"run 'http://localhost:4545/echo_server.ts' '"'"#) r#"run --no-config 'http://localhost:4545/echo_server.ts' '"'"#
); ));
} }
} }
@ -1060,12 +1081,12 @@ mod tests {
assert!(file_path.exists()); assert!(file_path.exists());
let mut expected_string = format!( let mut expected_string = format!(
"--import-map '{}' 'http://localhost:4545/cat.ts'", "--import-map '{}' --no-config 'http://localhost:4545/cat.ts'",
import_map_url import_map_url
); );
if cfg!(windows) { if cfg!(windows) {
expected_string = format!( expected_string = format!(
"\"--import-map\" \"{}\" \"http://localhost:4545/cat.ts\"", "\"--import-map\" \"{}\" \"--no-config\" \"http://localhost:4545/cat.ts\"",
import_map_url import_map_url
); );
} }
@ -1102,9 +1123,11 @@ mod tests {
} }
assert!(file_path.exists()); assert!(file_path.exists());
let mut expected_string = format!("run '{}'", &file_module_string); let mut expected_string =
format!("run --no-config '{}'", &file_module_string);
if cfg!(windows) { if cfg!(windows) {
expected_string = format!("\"run\" \"{}\"", &file_module_string); expected_string =
format!("\"run\" \"--no-config\" \"{}\"", &file_module_string);
} }
let content = fs::read_to_string(file_path).unwrap(); let content = fs::read_to_string(file_path).unwrap();