fastmod icon indicating copy to clipboard operation
fastmod copied to clipboard

Exit code 0, but arbitrary error messages with no matches

Open konsalex opened this issue 2 years ago • 3 comments

Hey folks,

The DX is a bit confusing when there are no matches, as the exit code is indeed 0 which is great, but the output for an example command: fastmod -- '--palette-(dark)-([\w-]+)' '--theme-${1}-palette-${2}' -g '!base.css' -g '*.{tsx,ts,js,jsx,css,pcss}' ./src

would be:

Warning: -g: No such file or directory (os error 2)
Warning: !base.css: No such file or directory (os error 2)
Warning: -g: No such file or directory (os error 2)
Warning: *.{tsx,ts,js,jsx,css,pcss}: No such file or directory (os error 2)

which took me quite some time to figure out that indeed it run smoothly, the selectors just did not match anything.

Am I doing something wrong myself maybe?

Edit:

I get this only on times that I need to prepend with -- to avoid throwing with --palette for example

konsalex avatar Sep 18 '23 13:09 konsalex

It looks like you used --, so everything after that is taken literally, not as a flag, including your -g.

swolchok avatar Sep 18 '23 15:09 swolchok

@swolchok without the double hyphen I get to an issue:

error: Found argument '--palette-(dark)-([\w-]+)' which wasn't expected, or isn't valid in this context

Then to solve this I try to escape the hyphens:

fastmod '\-\-palette-(dark)-([\w-]+)' '\-\-theme-${1}-palette-${2}' -g '!base.css' -g '*.{tsx,ts,js,jsx,css,pcss}' ./src

and this one leads to weird replacement

-                 color: "var(--palette-dark-neutral-bg)",
+                 color: "var(\-\-theme-dark-palette-neutral-bg)",

Do you have any clue how this one can be resolved?

konsalex avatar Sep 18 '23 17:09 konsalex

I think moving the flags before the double hyphen should do it: fastmod -g '!base.css' -g '*.{tsx,ts,js,jsx,css,pcss}' -- '--palette-(dark)-([\w-]+)' '--theme-${1}-palette-${2}' ./src

swolchok avatar Sep 26 '23 04:09 swolchok

Seems like this can be closed.

nk9 avatar Oct 05 '25 23:10 nk9