Skip to content

Instantly share code, notes, and snippets.

@jesseditson
Last active August 29, 2015 13:56
Show Gist options
  • Save jesseditson/8971069 to your computer and use it in GitHub Desktop.
Save jesseditson/8971069 to your computer and use it in GitHub Desktop.
node-debug
#!/bin/bash
node-inspector --web-port 8080 &
sleep 1
URL="http://127.0.0.1:8080/debug?port=5858"
echo "
tell application \"Google Chrome\"
set aWin to make new window with properties {mode:\"incognito\"}
tell aWin
activate
tell active tab
set URL to \"${URL}\"
end tell
end tell
end tell" | osascript
export WINDOW_ID=`osascript -e 'tell application "Google Chrome" to get id of the front window'`
echo "started inspector and opened window ${SAFARI_WINDOW_ID}"
function stopInspector {
echo "closing inspector window..."
osascript -e "tell application \"Google Chrome\" to close (every window whose id is $WINDOW_ID)"
INSPECTOR_PID=`pgrep -fl 'node-inspector --web-port' | awk '{ print $1 }'`
echo "stopping ${INSPECTOR_PID}..."
if [ -n "$INSPECTOR_PID" ]; then
kill $INSPECTOR_PID
sleep 1
fi
}
cmd=$@
if [[ $cmd != \-brk* ]]
then
cmd=" ${@}"
fi
echo "running: node --debug$cmd"
node --debug$cmd
trap stopInspector EXIT
{
"name": "node-debug-osx",
"version": "0.0.1",
"description": "Bash wrapper around the node-inspector that opens & closes Chrome windows and stuff",
"main": "index.js",
"author": "Jesse Ditson <jesse.ditson@gmail.com>",
"license": "BSD-2-Clause",
"bin" : "node-debug"
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment