Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

BREAKING: remove --ts flag #25338

Merged
merged 1 commit into from
Sep 2, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
84 changes: 32 additions & 52 deletions cli/args/flags.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2094,48 +2094,39 @@ Show documentation for runtime built-ins:
}

fn eval_subcommand() -> Command {
command("eval",
"Evaluate JavaScript from the command line.
command(
"eval",
"Evaluate JavaScript from the command line.

deno eval \"console.log('hello world')\"

To evaluate as TypeScript:
deno eval --ext=ts \"const v: string = 'hello'; console.log(v)\"

This command has implicit access to all permissions (--allow-all).",
UnstableArgsConfig::ResolutionAndRuntime,
)
.defer(|cmd| {
runtime_args(cmd, false, true)
.arg(check_arg(false))
.arg(
// TODO(@satyarohith): remove this argument in 2.0.
Arg::new("ts")
.conflicts_with("ext")
.long("ts")
.short('T')
.help("deprecated: Use `--ext=ts` instead. The `--ts` and `-T` flags are deprecated and will be removed in Deno 2.0.")
.action(ArgAction::SetTrue)
.hide(true),
)
.arg(executable_ext_arg())
.arg(
Arg::new("print")
.long("print")
.short('p')
.help("print result to stdout")
.action(ArgAction::SetTrue),
)
.arg(
Arg::new("code_arg")
.num_args(1..)
.action(ArgAction::Append)
.help("Code to evaluate")
.value_name("CODE_ARG")
.required_unless_present("help"),
)
.arg(env_file_arg())
})
UnstableArgsConfig::ResolutionAndRuntime,
)
.defer(|cmd| {
runtime_args(cmd, false, true)
.arg(check_arg(false))
.arg(executable_ext_arg())
.arg(
Arg::new("print")
.long("print")
.short('p')
.help("print result to stdout")
.action(ArgAction::SetTrue),
)
.arg(
Arg::new("code_arg")
.num_args(1..)
.action(ArgAction::Append)
.help("Code to evaluate")
.value_name("CODE_ARG")
.required_unless_present("help"),
)
.arg(env_file_arg())
})
}

fn fmt_subcommand() -> Command {
Expand Down Expand Up @@ -4317,21 +4308,6 @@ fn eval_parse(flags: &mut Flags, matches: &mut ArgMatches) {

ext_arg_parse(flags, matches);

// TODO(@satyarohith): remove this flag in 2.0.
let as_typescript = matches.get_flag("ts");

#[allow(clippy::print_stderr)]
if as_typescript {
eprintln!(
"⚠️ {}",
crate::colors::yellow(
"Use `--ext=ts` instead. The `--ts` and `-T` flags are deprecated and will be removed in Deno 2.0."
),
);

flags.ext = Some("ts".to_string());
}

let print = matches.get_flag("print");
let mut code_args = matches.remove_many::<String>("code_arg").unwrap();
let code = code_args.next().unwrap();
Expand Down Expand Up @@ -7033,8 +7009,12 @@ mod tests {

#[test]
fn eval_typescript() {
let r =
flags_from_vec(svec!["deno", "eval", "-T", "'console.log(\"hello\")'"]);
let r = flags_from_vec(svec![
"deno",
"eval",
"--ext=ts",
"'console.log(\"hello\")'"
]);
assert_eq!(
r.unwrap(),
Flags {
Expand Down