fix: do not panic on not found cwd (#10238)

This commit is contained in:
Satya Rohith 2021-04-21 21:22:00 +05:30 committed by GitHub
parent 320c19c7c0
commit 3b78f6c449
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
8 changed files with 43 additions and 6 deletions

View file

@ -1,6 +1,7 @@
// Copyright 2018-2021 the Deno authors. All rights reserved. MIT license.
use deno_core::error::AnyError;
use deno_core::error::Context;
pub use deno_core::normalize_path;
use deno_runtime::deno_crypto::rand;
use std::env::current_dir;
@ -81,7 +82,8 @@ pub fn resolve_from_cwd(path: &Path) -> Result<PathBuf, AnyError> {
let resolved_path = if path.is_absolute() {
path.to_owned()
} else {
let cwd = current_dir().unwrap();
let cwd =
current_dir().context("Failed to get current working directory")?;
cwd.join(path)
};