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

Error: nothing found to replace when no match found #104

Open
micisse opened this issue Sep 19, 2023 · 2 comments
Open

Error: nothing found to replace when no match found #104

micisse opened this issue Sep 19, 2023 · 2 comments

Comments

@micisse
Copy link

micisse commented Sep 19, 2023

In some cases, if no match is found, it's not a mistake.

For example: Read a folder with several files in it, then execute the ruplacer command for each file to replace, for example, "Hi" with "Bye" in each file read. If "Hi" is found, replace, otherwise skip (this should not be considered an error). If a match is found, OK, otherwise, SKIP. Wouldn't it be better to have a skip flag to prevent this behavior?

In my terminal, I get a lot of errors when there aren't any.

Capture d’écran_2023-09-19_23-52-43

Other proposal: With ripgrep for example, it's possible to display only the modified items in output and not the entire file content + changes, especially for large files. This could be an idea for a new feature flag.

Capture d’écran_2023-09-20_00-15-09

@dmerejkowsky
Copy link
Collaborator

This looks like a bug - the message should only get printed once. How did you run ruplacer ?

@micisse
Copy link
Author

micisse commented Sep 21, 2023

@dmerejkowsky In fact I use a regex on top of it to look for different files in which I want to make the changes. The ruplacer command is therefore called for each file in the loop, which is why the message is displayed several times, and that's normal. The problem is the error display. If ruplacer finds nothing, then there's nothing to change, so skip it (It's not a mistake). I don't pass global folder as arguments to ruplacer, but specific files.. For example:

// node
const result = /*find with regex somes files*/

result.forEach((file) => {
     const command = `ruplacer --go "find" "replace with" "${file}"`
    ...
})

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

No branches or pull requests

2 participants