Skip to content

Fix --js code running for a file with no match to close #859 - #860

Open
mathiasrw wants to merge 1 commit into
fix/854from
fix/859
Open

mathiasrw wants to merge 1 commit into
fix/854from
fix/859

Conversation

@mathiasrw

Copy link
Copy Markdown
Owner

Closes #859

Stacked on #855.

Change

--js code that runs once per file now runs at the first match of the file. A file with no match does not run it. Before, it ran at the start of every file, and the value was then not used for a file with no match. So code with a side effect, like printing or writing a file, ran for files it did not change, and an error in the code was told for the first file, also when it had no match.

The help and the README say: "For speed, the code runs once per file, at its first match, unless it names the match, a group, $m or $M. A file without a match does not run the code."

For the release note of v8: code with a side effect now only runs for a file with a match.

Tests

test/fix/859.test.js is new, and 2 of its 3 tests fail without the fix: a file with no match does not run the code, and an error is told for the first file with a match. The third checks that a file with two matches still runs the code once. yarn test-ci passes.

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.

1 participant