mirror of
https://github.com/cobalt-org/cobalt.rs
synced 2024-11-13 23:47:09 +00:00
parent
a8a7aa6e5b
commit
c15d36a282
4 changed files with 12 additions and 6 deletions
|
@ -1,5 +1,11 @@
|
|||
fn main() {
|
||||
let path = std::env::current_dir().unwrap();
|
||||
let path = match std::env::current_dir() {
|
||||
Ok(path) => path,
|
||||
Err(err) => {
|
||||
eprintln!("Cannot serve CWD: {}", err);
|
||||
std::process::exit(1);
|
||||
}
|
||||
};
|
||||
let server = file_serve::Server::new(&path);
|
||||
|
||||
println!("Serving {}", path.display());
|
||||
|
|
|
@ -35,7 +35,7 @@ impl ConfigArgs {
|
|||
failure::format_err!("Error reading config file {:?}", config_path)
|
||||
})?
|
||||
} else {
|
||||
let cwd = env::current_dir().expect("How does this fail?");
|
||||
let cwd = env::current_dir().unwrap_or_default();
|
||||
cobalt_config::Config::from_cwd(cwd)?
|
||||
};
|
||||
|
||||
|
|
|
@ -52,7 +52,7 @@ impl CleanArgs {
|
|||
}
|
||||
|
||||
pub fn clean(config: &cobalt::Config) -> Result<()> {
|
||||
let cwd = env::current_dir().unwrap_or_else(|_| path::PathBuf::new());
|
||||
let cwd = env::current_dir().unwrap_or_default();
|
||||
let destdir = dunce::canonicalize(&config.destination);
|
||||
let destdir = match destdir {
|
||||
Ok(destdir) => destdir,
|
||||
|
|
|
@ -58,7 +58,7 @@ impl NewArgs {
|
|||
|
||||
let title = self.title.as_deref();
|
||||
|
||||
let mut file = env::current_dir().expect("How does this fail?");
|
||||
let mut file = env::current_dir().unwrap_or_default();
|
||||
if let Some(rel_file) = self.file.as_deref() {
|
||||
file.push(rel_file)
|
||||
}
|
||||
|
@ -100,7 +100,7 @@ impl RenameArgs {
|
|||
|
||||
let title = self.title.as_ref();
|
||||
|
||||
let mut file = env::current_dir().expect("How does this fail?");
|
||||
let mut file = env::current_dir().unwrap_or_default();
|
||||
if let Some(rel_file) = self.file.as_deref() {
|
||||
file.push(rel_file)
|
||||
}
|
||||
|
@ -130,7 +130,7 @@ impl PublishArgs {
|
|||
let config = cobalt::cobalt_model::Config::from_config(config)?;
|
||||
|
||||
let filename = self.filename.as_path();
|
||||
let mut file = env::current_dir().expect("How does this fail?");
|
||||
let mut file = env::current_dir().unwrap_or_default();
|
||||
file.push(path::Path::new(filename));
|
||||
|
||||
publish_document(&config, &file)
|
||||
|
|
Loading…
Reference in a new issue