summaryrefslogtreecommitdiff
path: root/cli/compilers
diff options
context:
space:
mode:
authorYoshiya Hinosawa <stibium121@gmail.com>2019-09-20 23:19:51 +0900
committerRyan Dahl <ry@tinyclouds.org>2019-09-20 10:19:51 -0400
commit560edc536c67d55001e679e6179a8959e4ac727f (patch)
treeefed58b7e6486818d8f92db300730cbd9af3d9a3 /cli/compilers
parent7f90b7826dbcd39514daf8240e5ec2729e67c11f (diff)
Fix handling of config file (#2996)
Diffstat (limited to 'cli/compilers')
-rw-r--r--cli/compilers/ts.rs26
1 files changed, 25 insertions, 1 deletions
diff --git a/cli/compilers/ts.rs b/cli/compilers/ts.rs
index fc280a898..3e92e5ccf 100644
--- a/cli/compilers/ts.rs
+++ b/cli/compilers/ts.rs
@@ -22,6 +22,7 @@ use ring;
use std::collections::HashSet;
use std::fmt::Write;
use std::fs;
+use std::io;
use std::path::PathBuf;
use std::str;
use std::sync::atomic::Ordering;
@@ -60,7 +61,20 @@ impl CompilerConfig {
// Convert the PathBuf to a canonicalized string. This is needed by the
// compiler to properly deal with the configuration.
let config_path = match &config_file {
- Some(config_file) => Some(config_file.canonicalize().unwrap().to_owned()),
+ Some(config_file) => Some(
+ config_file
+ .canonicalize()
+ .map_err(|_| {
+ io::Error::new(
+ io::ErrorKind::InvalidInput,
+ format!(
+ "Could not find the config file: {}",
+ config_file.to_string_lossy()
+ ),
+ )
+ })?
+ .to_owned(),
+ ),
_ => None,
};
@@ -773,4 +787,14 @@ mod tests {
assert_eq!(config.compile_js, expected);
}
}
+
+ #[test]
+ fn test_compiler_config_load() {
+ let temp_dir = TempDir::new().expect("tempdir fail");
+ let temp_dir_path = temp_dir.path();
+ let path = temp_dir_path.join("doesnotexist.json");
+ let path_str = path.to_str().unwrap().to_string();
+ let res = CompilerConfig::load(Some(path_str.clone()));
+ assert!(res.is_err());
+ }
}