From ae58f6774460b3eb5b978bf51833de08b0c52871 Mon Sep 17 00:00:00 2001 From: Martijn Laarman Date: Sun, 27 Nov 2011 11:44:12 +0100 Subject: [PATCH 1/3] %NODE_INSPECTOR_BROWSER% needed quoting for filepaths with spaces --- node-debug.cmd | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/node-debug.cmd b/node-debug.cmd index dd529ac..2250ad2 100644 --- a/node-debug.cmd +++ b/node-debug.cmd @@ -7,5 +7,5 @@ if exist "%NODE_INSPECTOR%\environmentvars.bat" ( start "" "cmd" "/k node --debug-brk app.js" ) -start "" %NODE_INSPECTOR_BROWSER% "http://localhost:8080" -echo start "" %NODE_INSPECTOR_BROWSER% "%1%" \ No newline at end of file +start "" "%NODE_INSPECTOR_BROWSER%" "http://localhost:8080" +echo start "" "%NODE_INSPECTOR_BROWSER%" "%1%" \ No newline at end of file From 3972ad8c4dda1eafd50205f4b9a654301db09c8a Mon Sep 17 00:00:00 2001 From: Martijn Laarman Date: Sun, 27 Nov 2011 13:13:30 +0100 Subject: [PATCH 2/3] Added support for `coffee` debugging. node-debug [-c] [-p PORT] --- .gitignore | 2 ++ README.md | 12 ++++++------ environmentvars.bat | 4 ++-- node-debug.cmd | 42 +++++++++++++++++++++++++++++++++--------- 4 files changed, 43 insertions(+), 17 deletions(-) create mode 100644 .gitignore diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..4ae3d50 --- /dev/null +++ b/.gitignore @@ -0,0 +1,2 @@ + +/node_modules \ No newline at end of file diff --git a/README.md b/README.md index eb036f2..d710d75 100644 --- a/README.md +++ b/README.md @@ -15,27 +15,27 @@ Tool for getting node-inspector working on windows and for simplifying the proce - Windows - [Latest npm build for windows] (http://npmjs.org/doc/README.html#Installing-on-Windows-Experimental) - **Installation** - From the command window launch install.cmd. This will install node-inspector via npm and apply the paperboy patch described [here] (https://github.com/dannycoates/node-inspector/issues/62#issuecomment-1998429) to get node-inspector working on windows. - From the start menu right click on Computer->Properties->Advanced Computer Settings->Environment variables. - Create 2 system variables - set NODE_INSPECTOR to the folder where this repo is located i.e. "c:\node-inspector" - - set NODE_INSPECTOR_BROWSER to the path of your webkit browser of choice i.e. Chrome, Safari. For example right clicking on Chrome on my machine gives me “C:\Users\gblock\AppData\Local\Google\Chrome\Application\chrome.exe” - Add %NODE_INSPECTOR% to your path. **Using** +- node-debug [-c] [-p PORT] +-c will run coffee app.coffee in debug mode otherwise +-p will start node-inspector on the provided port. + - In the command window, go to the folder where the node app you want to debug is. -- Type node-debug [url] e.g. node-debug http://localhost:3000 +- Type node-debug Once you run it from the app folder it will: - Launch node inspector -- Launch you app in debug mode. -- Open the browser you specified and launch the debugger ui. -- Launch the start url you specified. +- Launch your app in debug mode. (either through `node` or `coffee` depending on the `-c` switch) **Known issues** I've seen some cases where running node-debug causes a socket error. This seems to happen periodically. Closing the command windows and starting again seems to clear it. diff --git a/environmentvars.bat b/environmentvars.bat index 922859a..3d5f5ac 100644 --- a/environmentvars.bat +++ b/environmentvars.bat @@ -1,2 +1,2 @@ -REM Set environment variables here -REM example: SET MY_VARIABLE=MY_VALUE \ No newline at end of file +@REM Set environment variables here +@REM example: SET MY_VARIABLE=MY_VALUE \ No newline at end of file diff --git a/node-debug.cmd b/node-debug.cmd index 2250ad2..5147683 100644 --- a/node-debug.cmd +++ b/node-debug.cmd @@ -1,11 +1,35 @@ -@echo off -start "" "cmd" "/k cd %NODE_INSPECTOR%\node_modules\node-inspector\bin&&node inspector &" +@ECHO off +SET PORT=8080 +SET COFFEEDEBUG=0 +SET RUNENVBAT=0 +IF EXIST "%NODE_INSPECTOR%\environmentvars.bat" SET RUNENVBAT=1 -if exist "%NODE_INSPECTOR%\environmentvars.bat" ( - start "" "cmd" "/k %NODE_INSPECTOR%\environmentvars.bat&&node --debug-brk app.js" -) else ( - start "" "cmd" "/k node --debug-brk app.js" -) +IF "%1"=="" GOTO APPSTART +:GETOPTS + IF /I %1 == -c SET COFFEEDEBUG=1& + IF /I %1 == -p SET PORT=%2& SHIFT + SHIFT +IF NOT (%1)==() GOTO GETOPTS + +:APPSTART -start "" "%NODE_INSPECTOR_BROWSER%" "http://localhost:8080" -echo start "" "%NODE_INSPECTOR_BROWSER%" "%1%" \ No newline at end of file +START "" "cmd" "/k cd %NODE_INSPECTOR%\node_modules\node-inspector\bin&&node inspector --web-port=%PORT%&" +ECHO started node-inspector on port:%PORT% +IF %COFFEEDEBUG% == 1 IF %RUNENVBAT% == 1 ( + START "" "cmd" "/k %NODE_INSPECTOR%\environmentvars.bat&&coffee --nodejs --debug app.coffee" + ECHO applied environmentvars.bat + ECHO started coffee --nodejs --debug app.coffee +) +IF %COFFEEDEBUG% == 1 IF %RUNENVBAT% == 0 ( + START "" "cmd" "/k coffee --nodejs --debug app.coffee" + ECHO started coffee --nodejs --debug app.coffee +) +IF %COFFEEDEBUG% == 0 IF %RUNENVBAT% == 1 ( + START "" "cmd" "/k %NODE_INSPECTOR%\environmentvars.bat&&node --debug-brk app.js" + ECHO applied environmentvars.bat + ECHO started node --debug-brk app.js +) +IF %COFFEEDEBUG% == 0 IF %RUNENVBAT% == 0 ( + START "" "cmd" "/k node --debug-brk app.js" + ECHO started node +) From 4798d30b0ef6c6a9e86bc9ea8bcd5502594db397 Mon Sep 17 00:00:00 2001 From: Martijn Laarman Date: Sun, 27 Nov 2011 13:14:56 +0100 Subject: [PATCH 3/3] mardown formatting --- README.md | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/README.md b/README.md index d710d75..6363475 100644 --- a/README.md +++ b/README.md @@ -26,9 +26,8 @@ Tool for getting node-inspector working on windows and for simplifying the proce **Using** - node-debug [-c] [-p PORT] --c will run coffee app.coffee in debug mode otherwise --p will start node-inspector on the provided port. - + -c will run coffee app.coffee in debug mode otherwise + -p will start node-inspector on the provided port. - In the command window, go to the folder where the node app you want to debug is. - Type node-debug