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

feat(cli): add DENO_CERT environment variable (#6370)

This commit is contained in:
Oscar Linde 2020-07-13 01:18:27 +02:00 committed by GitHub
parent e1d8140552
commit 3be2064803
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
3 changed files with 27 additions and 1 deletions

View file

@ -186,6 +186,7 @@ static ENV_VARIABLES_HELP: &str = "ENVIRONMENT VARIABLES:
DENO_DIR Set the cache directory
DENO_INSTALL_ROOT Set deno install's output directory
(defaults to $HOME/.deno/bin)
DENO_CERT Load certificate authority from PEM encoded file
NO_COLOR Set to disable color
HTTP_PROXY Proxy address for HTTP requests
(module downloads, fetch)

View file

@ -58,6 +58,10 @@ impl GlobalState {
let dir = deno_dir::DenoDir::new(custom_root)?;
let deps_cache_location = dir.root.join("deps");
let http_cache = http_cache::HttpCache::new(&deps_cache_location);
let ca_file = flags
.ca_file
.clone()
.or_else(|| env::var("DENO_CERT").map(String::into).ok());
let file_fetcher = SourceFileFetcher::new(
http_cache,
@ -65,7 +69,7 @@ impl GlobalState {
flags.cache_blocklist.clone(),
flags.no_remote,
flags.cached_only,
flags.ca_file.clone(),
ca_file,
)?;
let ts_compiler = TsCompiler::new(

View file

@ -2182,6 +2182,27 @@ itest!(deno_lint_glob {
exit_code: 1,
});
#[test]
fn cafile_env_fetch() {
use url::Url;
let g = util::http_server();
let deno_dir = TempDir::new().expect("tempdir fail");
let module_url =
Url::parse("https://localhost:5545/cli/tests/cafile_url_imports.ts")
.unwrap();
let cafile = util::root_path().join("cli/tests/tls/RootCA.pem");
let output = Command::new(util::deno_exe_path())
.env("DENO_DIR", deno_dir.path())
.env("DENO_CERT", cafile)
.current_dir(util::root_path())
.arg("cache")
.arg(module_url.to_string())
.output()
.expect("Failed to spawn script");
assert!(output.status.success());
drop(g);
}
#[test]
fn cafile_fetch() {
use url::Url;