Skip to content

Conversation

@gn00295120
Copy link
Contributor

Summary

Fixes #30958 by removing the require_equals(true) constraint from the --eval-file flag, making the equals sign optional.

Problem

The --eval-file flag currently requires an equals sign (--eval-file=file.ts), which makes it impossible to use in hashbang contexts where arguments cannot contain equals signs.

Solution

Removed .require_equals(true) from the flag definition in cli/args/flags.rs, allowing both syntaxes:

  • deno repl --eval-file script.ts (new, works with hashbangs)
  • deno repl --eval-file=script.ts (still works, backwards compatible)
  • deno repl --eval-file 1.ts --eval-file 2.ts (multiple files)

Changes

  • Removed require_equals(true) constraint from --eval-file flag
  • Added test case for using flag without equals sign
  • Added test case for multiple --eval-file flags

Testing

Added two new test cases:

  1. repl_with_eval_file_flag_no_equals - Tests --eval-file script.ts syntax
  2. repl_with_eval_file_flag_multiple - Tests multiple flags

The existing test repl_with_eval_file_flag continues to work, ensuring backwards compatibility.

Use Case

This enables the following hashbang usage:

#!/usr/bin/env -S deno repl --allow-read --eval-file
console.log('hello from data.ts')

Copilot AI review requested due to automatic review settings October 31, 2025 17:32
@CLAassistant
Copy link

CLAassistant commented Oct 31, 2025

CLA assistant check
All committers have signed the CLA.

Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull Request Overview

This PR removes the require_equals(true) constraint from the --eval-file flag in the REPL subcommand to enable more flexible usage patterns, particularly for hashbang scripts. The change allows users to specify eval files using both --eval-file=path and --eval-file path syntax.

  • Removed .require_equals(true) from the --eval-file flag definition
  • Added test coverage for space-separated syntax: --eval-file ./script.ts
  • Added test coverage for multiple flag usage: --eval-file ./a.ts --eval-file ./b.ts

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Removes the `require_equals(true)` constraint from the `--eval-file` flag
in the REPL subcommand, allowing it to be used in hashbang contexts where
the equals sign cannot be provided.

This change enables the following usage patterns:
- `deno repl --eval-file script.ts` (new)
- `deno repl --eval-file=script.ts` (still works)
- `deno repl --eval-file 1.ts --eval-file 2.ts` (multiple files)

Also adds test coverage for:
- Using --eval-file without equals sign
- Multiple --eval-file flags

Fixes denoland#30958
@gn00295120 gn00295120 force-pushed the fix-eval-file-flag-30958 branch from ce757ba to 7076fa5 Compare October 31, 2025 17:38
This addresses the Copilot PR review feedback that removing
require_equals(true) would break the comma-separated syntax in
the existing test at line 8782. Adding use_value_delimiter(true)
maintains backward compatibility with:
- Comma-separated values: --eval-file=./a.js,./b.ts,./c.ts
- Space-separated syntax: --eval-file ./script.ts
- Multiple flags: --eval-file ./a.ts --eval-file ./b.ts

This change aligns with other flags in the codebase that support
multiple values (allow-net, allow-env, etc.).
Format vec! declarations to single line as per dprint requirements.
Copy link
Member

@dsherret dsherret left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@dsherret dsherret merged commit b04d451 into denoland:main Nov 3, 2025
19 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

--eval-file requires =, impossible to provide from #!

3 participants