CoffeeScript - 使用参数执行bash脚本

eou*_*uti 5 javascript bash coffeescript hubot

我正在玩GitHub的Hubot,我尝试在我的机器人工作中执行一个bash脚本.
我成功执行了我的脚本,但如果我在这个脚本中添加一些参数,则无法使其正常工作.

{ spawn } = require 'child_process'
s = spawn './myScript.sh' + " url" + " title"     <------- doesn't work due to args
s = spawn './myScript.sh'                         <------- alright without args
s.stdout.on 'data', ( data ) -> console.log "Output: #{ data }"
s.stderr.on 'data', ( data ) -> console.error "Error: #{ data }"
s.on 'close', -> console.log "'s' has finished executing."
Run Code Online (Sandbox Code Playgroud)

如何将参数传递给我的脚本?
感谢帮助

Aur*_*iot 8

如文档中所述:

http://nodejs.org/api/child_process.html#child_process_child_process_spawn_command_args_options

Spawn采用由不同参数组成的数组作为第二个参数.它看起来像这样:

s = spawn './myScript.sh', [url, title]
Run Code Online (Sandbox Code Playgroud)