fix(npm): resolve node_modules dir relative to package.json instead of cwd (#17885)

This commit is contained in:
David Sherret 2023-02-22 20:16:16 -05:00 committed by GitHub
parent a31d8869ea
commit ddc350780d
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
12 changed files with 219 additions and 141 deletions

View file

@ -2753,6 +2753,8 @@ itest!(package_json_auto_discovered_for_local_script_log {
args: "run -L debug -A no_deno_json/main.ts",
output: "run/with_package_json/no_deno_json/main.out",
maybe_cwd: Some("run/with_package_json/"),
// prevent creating a node_modules dir in the code directory
copy_temp_dir: Some("run/with_package_json/"),
envs: env_vars_for_npm_tests_no_sync_download(),
http_server: true,
});
@ -2764,16 +2766,29 @@ itest!(
args: "run -L debug with_stop/some/nested/dir/main.ts",
output: "run/with_package_json/with_stop/main.out",
maybe_cwd: Some("run/with_package_json/"),
copy_temp_dir: Some("run/with_package_json/"),
envs: env_vars_for_npm_tests_no_sync_download(),
http_server: true,
exit_code: 1,
}
);
itest!(
package_json_auto_discovered_node_modules_relative_package_json {
args: "run -A main.js",
output: "run/with_package_json/no_deno_json/sub_dir/main.out",
maybe_cwd: Some("run/with_package_json/no_deno_json/sub_dir"),
copy_temp_dir: Some("run/with_package_json/"),
envs: env_vars_for_npm_tests_no_sync_download(),
http_server: true,
}
);
itest!(package_json_auto_discovered_for_npm_binary {
args: "run -L debug -A npm:@denotest/bin/cli-esm this is a test",
output: "run/with_package_json/npm_binary/main.out",
maybe_cwd: Some("run/with_package_json/npm_binary/"),
copy_temp_dir: Some("run/with_package_json/"),
envs: env_vars_for_npm_tests_no_sync_download(),
http_server: true,
});