Ale*_*lls 7 macos bash node.js
好吧,这是一个有趣的,我们得到以下标准:
Debugger listening on port 9229.
Warning: This is an experimental feature and could change at any time.
To start debugging, open the following URL in Chrome:
chrome-devtools://devtools/remote/serve_file/@60cd6e859b9f557d2312f5bf532f6aec5f284980/inspector.html?experiments=true&v8only=true&ws=127.0.0.1:9229/a7a2a58d-dfd1-4cc6-875c-47da78adeb1b
Run Code Online (Sandbox Code Playgroud)
当我们运行这样的命令时:
node --inspect --debug-brk bin/www.js
Run Code Online (Sandbox Code Playgroud)
我在考虑创建一个像这样的bash脚本:
#!/usr/bin/env bash
NODE_DEBUG_OUTPUT=$(node --inspect --debug-brk bin/www.js)
open -a "/Applications/Google Chrome.app"/ getUrl(${NODE_DEBUG_OUTPUT})
Run Code Online (Sandbox Code Playgroud)
但这里是我的bash技能结束的地方 - 我如何实现该getUrl功能,以便我可以从输出中获取url?
我很确定如果我们将一个url传递给bash中的open函数,它将打开一个浏览器,在这种情况下它必须是谷歌Chrome浏览器.
Ale*_*lls -1
这真的很接近!唯一不起作用的是 chrome 实际上并没有打开 url,它只是打开到 google.com
export PATH=$PATH:/Applications/Google\ Chrome.app/Contents/MacOS/
(node --inspect --debug-brk bin/www.js $@ &> debug-server.log) &
sleep 1; // wait for the stdout to get written to file...
LINE=$(grep -n "chrome-devtools" debug-server.log | awk '{print $2}')
echo " => Supposed chrome-devtools link => '$LINE'";
Google\ Chrome "${LINE}"
Run Code Online (Sandbox Code Playgroud)
有人知道为什么“Google\ Chrome”命令不会打开作为第一个参数提供的网址吗?