diff options
Diffstat (limited to 'cli/main.rs')
-rw-r--r-- | cli/main.rs | 37 |
1 files changed, 20 insertions, 17 deletions
diff --git a/cli/main.rs b/cli/main.rs index 37d5edc58..c67875fe8 100644 --- a/cli/main.rs +++ b/cli/main.rs @@ -80,8 +80,8 @@ use crate::global_state::GlobalState; use crate::msg::MediaType; use crate::permissions::Permissions; use crate::worker::MainWorker; +use deno_core::error::AnyError; use deno_core::v8_set_flags; -use deno_core::ErrBox; use deno_core::ModuleSpecifier; use deno_doc as doc; use deno_doc::parser::DocFileLoader; @@ -113,18 +113,18 @@ fn write_to_stdout_ignore_sigpipe(bytes: &[u8]) -> Result<(), std::io::Error> { } } -fn write_json_to_stdout<T>(value: &T) -> Result<(), ErrBox> +fn write_json_to_stdout<T>(value: &T) -> Result<(), AnyError> where T: ?Sized + serde::ser::Serialize, { let writer = std::io::BufWriter::new(std::io::stdout()); - serde_json::to_writer_pretty(writer, value).map_err(ErrBox::from) + serde_json::to_writer_pretty(writer, value).map_err(AnyError::from) } fn print_cache_info( state: &Arc<GlobalState>, json: bool, -) -> Result<(), ErrBox> { +) -> Result<(), AnyError> { let deno_dir = &state.dir.root; let modules_cache = &state.file_fetcher.http_cache.location; let typescript_cache = &state.dir.gen_cache.location; @@ -171,7 +171,7 @@ async fn info_command( flags: Flags, file: Option<String>, json: bool, -) -> Result<(), ErrBox> { +) -> Result<(), AnyError> { if json && !flags.unstable { exit_unstable("--json"); } @@ -200,7 +200,7 @@ async fn install_command( name: Option<String>, root: Option<PathBuf>, force: bool, -) -> Result<(), ErrBox> { +) -> Result<(), AnyError> { installer::install(flags, &module_url, args, name, root, force).await } @@ -210,7 +210,7 @@ async fn lint_command( list_rules: bool, ignore: Vec<String>, json: bool, -) -> Result<(), ErrBox> { +) -> Result<(), AnyError> { if !flags.unstable { exit_unstable("lint"); } @@ -223,7 +223,10 @@ async fn lint_command( lint::lint_files(files, ignore, json).await } -async fn cache_command(flags: Flags, files: Vec<String>) -> Result<(), ErrBox> { +async fn cache_command( + flags: Flags, + files: Vec<String>, +) -> Result<(), AnyError> { let main_module = ModuleSpecifier::resolve_url_or_path("./$deno$cache.ts").unwrap(); let global_state = GlobalState::new(flags)?; @@ -244,7 +247,7 @@ async fn eval_command( code: String, as_typescript: bool, print: bool, -) -> Result<(), ErrBox> { +) -> Result<(), AnyError> { // Force TypeScript compile. let main_module = ModuleSpecifier::resolve_url_or_path("./$deno$eval.ts").unwrap(); @@ -287,7 +290,7 @@ async fn bundle_command( flags: Flags, source_file: String, out_file: Option<PathBuf>, -) -> Result<(), ErrBox> { +) -> Result<(), AnyError> { let module_specifier = ModuleSpecifier::resolve_url_or_path(&source_file)?; debug!(">>>>> bundle START"); @@ -328,7 +331,7 @@ async fn doc_command( json: bool, maybe_filter: Option<String>, private: bool, -) -> Result<(), ErrBox> { +) -> Result<(), AnyError> { let global_state = GlobalState::new(flags.clone())?; let source_file = source_file.unwrap_or_else(|| "--builtin".to_string()); @@ -422,11 +425,11 @@ async fn doc_command( ) }; - write_to_stdout_ignore_sigpipe(details.as_bytes()).map_err(ErrBox::from) + write_to_stdout_ignore_sigpipe(details.as_bytes()).map_err(AnyError::from) } } -async fn run_repl(flags: Flags) -> Result<(), ErrBox> { +async fn run_repl(flags: Flags) -> Result<(), AnyError> { let main_module = ModuleSpecifier::resolve_url_or_path("./$deno$repl.ts").unwrap(); let global_state = GlobalState::new(flags)?; @@ -436,7 +439,7 @@ async fn run_repl(flags: Flags) -> Result<(), ErrBox> { } } -async fn run_from_stdin(flags: Flags) -> Result<(), ErrBox> { +async fn run_from_stdin(flags: Flags) -> Result<(), AnyError> { let global_state = GlobalState::new(flags.clone())?; let main_module = ModuleSpecifier::resolve_url_or_path("./$deno$stdin.ts").unwrap(); @@ -468,7 +471,7 @@ async fn run_from_stdin(flags: Flags) -> Result<(), ErrBox> { Ok(()) } -async fn run_with_watch(flags: Flags, script: String) -> Result<(), ErrBox> { +async fn run_with_watch(flags: Flags, script: String) -> Result<(), AnyError> { let main_module = ModuleSpecifier::resolve_url_or_path(&script)?; let global_state = GlobalState::new(flags.clone())?; @@ -510,7 +513,7 @@ async fn run_with_watch(flags: Flags, script: String) -> Result<(), ErrBox> { .await } -async fn run_command(flags: Flags, script: String) -> Result<(), ErrBox> { +async fn run_command(flags: Flags, script: String) -> Result<(), AnyError> { // Read script content from stdin if script == "-" { return run_from_stdin(flags).await; @@ -539,7 +542,7 @@ async fn test_command( allow_none: bool, filter: Option<String>, coverage: bool, -) -> Result<(), ErrBox> { +) -> Result<(), AnyError> { let global_state = GlobalState::new(flags.clone())?; let cwd = std::env::current_dir().expect("No current directory"); let include = include.unwrap_or_else(|| vec![".".to_string()]); |