diff options
author | Satya Rohith <me@satyarohith.com> | 2021-02-21 22:28:32 +0530 |
---|---|---|
committer | GitHub <noreply@github.com> | 2021-02-21 17:58:32 +0100 |
commit | 06fcfc5c0a2e39f0b723914bb2edb74a99c67bfb (patch) | |
tree | 39f7f2ab171f86ac3dd4dde60f4b1590ec55b5d3 /cli/main.rs | |
parent | fe1b512820cbdfd2b93ddfc8e935556878339425 (diff) |
feat: add --ext flag to deno eval (#9295)
This PR deprecates the "--ts"/"-T" flag of "deno eval" (which will later be removed in 2.0)
and introduces "--ext" which is used by "deno fmt" for content type selection.
This is to ensure we have a single flag that can be used across subcommands
to select the language (JS/TS).
Diffstat (limited to 'cli/main.rs')
-rw-r--r-- | cli/main.rs | 18 |
1 files changed, 10 insertions, 8 deletions
diff --git a/cli/main.rs b/cli/main.rs index 779c45d53..b9516e704 100644 --- a/cli/main.rs +++ b/cli/main.rs @@ -472,7 +472,7 @@ async fn cache_command( async fn eval_command( flags: Flags, code: String, - as_typescript: bool, + ext: String, print: bool, ) -> Result<(), AnyError> { // Force TypeScript compile. @@ -492,10 +492,14 @@ async fn eval_command( let file = File { local: main_module.clone().to_file_path().unwrap(), maybe_types: None, - media_type: if as_typescript { + media_type: if ext.as_str() == "ts" { MediaType::TypeScript - } else { + } else if ext.as_str() == "tsx" { + MediaType::TSX + } else if ext.as_str() == "js" { MediaType::JavaScript + } else { + MediaType::JSX }, source: String::from_utf8(source_code)?, specifier: main_module.clone(), @@ -1154,11 +1158,9 @@ fn get_subcommand( filter, private, } => doc_command(flags, source_file, json, filter, private).boxed_local(), - DenoSubcommand::Eval { - print, - code, - as_typescript, - } => eval_command(flags, code, as_typescript, print).boxed_local(), + DenoSubcommand::Eval { print, code, ext } => { + eval_command(flags, code, ext, print).boxed_local() + } DenoSubcommand::Cache { files } => { cache_command(flags, files).boxed_local() } |