I'm not sure how NPM is escaping the string and delivering it on the command line/terminal, but you can likely fix this with some standard tricks on double packed strings.
There are two passes of string parsing that happens here - first the JSON in the package.json
file is sent to NPM, then NPM sends the string to the terminal/command line. So you need to figure out how to embed the inner quotes in a way that they will get to the command line (in a way that agrees with git).
Try the following:
Reverse the single and double quotes (single quotes outside)
Add backslash in front of the inner quotes
- Backslash is typically an escape character for special characters
- When parsing a string, quotes are special characters
Add backslash in front of the inner quotes after switching them from single to double quotes
Try duplicating all the interior quotes (i.e. instead of '%C(cyan)...'
try ''%C(cyan)...''
or ""%C(cyan)...""
). Sometime parsers will treat duplicate quotes as an escape character and put just a single quote in the final output that is passed on.
How do I know this is the root cause?
The clue here is the error output. If you find the first "%H" in your string, you see there is a space right before it. If the single quotes get stripped out, then git will see the space, and consider the text after it to be the start of a new argument.
Git doesn't recognize "%H" as valid for whatever that argument would have been, and the error message it printed was the result.