Problem passing arguments to NodeJS using YAML event hook command

What is the problem?
Cannot pass arguments to NodeJS script using YAML event hook. The code into the config.yaml file is:

events:
  enabled: True
  subscriptions:
    - event: Connected
      command: /usr/bin/node /home/pi/prototype-rasp/listenPrintStarted.js "foo" "bar"
      type: system
      enabled: true

I could verify that the event occurs and the listenPrintStarted.js will be fired since I can see its logs, but the process.argv contains only process.argv is: ['/usr/bin/node', '/home/pi/prototype-rasp/listenPrintStarted.js'].

What did you already try to solve it?
I tested launching the same exact command out of YAML, running it directly in the command line and so it works. In fact, running: $ /usr/bin/node /home/pi/prototype-rasp/listenPrintStarted.js "foo" "bar" I get in the logs of the script: process.argv is: ['/usr/bin/node', '/home/pi/prototype-rasp/listenPrintStarted.js', 'foo', 'bar'].

Additional information about your setup
OctoPrint version : 1.3.10
OctoPi version : 0.16.0

How to pass foo and bar when OctoPrint event occurs?

Looks like the underlying code suggests that if you turn on debugging in the Settings then it will tell you in the octoprint.log what it tried to send.

		def commandExecutioner(cmd):
			if debug:
				self._logger.info("Executing system command: {}".format(cmd))
			else:
				self._logger.info("Executing a system command")
			# we run this with shell=True since we have to trust whatever
			# our admin configured as command and since we want to allow
			# shell-alike handling here...
			subprocess.check_call(cmd, shell=True)

You could see if the perhaps the _processCommand() whacked your command.

Another way of doing this might be to add a shebang to the top of listenPrintStarted.js which points to #!/usr/bin/node. You might then change your line to:

   command: /home/pi/prototype-rasp/listenPrintStarted.js "foo" "bar"