Fix Chrome paths with spaces by neeeeecka · Pull Request #770 · prerender/prerender

The issue:

On MacOs the Chrome would not start, shell command ran but exited:
image

The reason:

The backslashes in - /Applications/Google\ Chrome.app/Contents/MacOS/Google\ Chrome are not interpreted as literal characters by JS, but rather ignored and the resulting JS string was: /Applications/Google Chrome.app/Contents/MacOS/Google Chrome.

Fix:

To resolve this, we need to escape whitespaces as we would escape them in a shell command, by wrapping it in double quotes:
"/Applications/Google Chrome.app/Contents/MacOS/Google Chrome"

Related: nodejs/node#7367 (comment)

Tested on:
MacOS: 13.2.1
NodeJS: v14.21.3