File tree Expand file tree Collapse file tree 4 files changed +40
-1
lines changed Expand file tree Collapse file tree 4 files changed +40
-1
lines changed Original file line number Diff line number Diff line change @@ -228,3 +228,26 @@ You must export a Function that returns a Promise. Your function will be called
228
228
* tag - The value of ` --tag `
229
229
230
230
You should use ` ora ` to indicate your publish progress.
231
+
232
+ ## Debugging your application through VS Code
233
+
234
+ Debugging your Electron main process through VS Code is ridiculously
235
+ easy with Forge. Simply add this as a launch config in VSCode and you're
236
+ good to go.
237
+
238
+ ``` json
239
+ {
240
+ "type" : " node" ,
241
+ "request" : " launch" ,
242
+ "name" : " Electron Main" ,
243
+ "runtimeExecutable" : " ${workspaceRoot}/node_modules/.bin/electron-forge-vscode-nix" ,
244
+ "windows" : {
245
+ "runtimeExecutable" : " ${workspaceRoot}/node_modules/.bin/electron-forge-vscode-win.cmd"
246
+ },
247
+ // runtimeArgs will be passed directly to your Electron application
248
+ "runtimeArgs" : [
249
+ " foo" ,
250
+ " bar"
251
+ ]
252
+ }
253
+ ```
Original file line number Diff line number Diff line change 6
6
"main" : " dist/api/index.js" ,
7
7
"bin" : {
8
8
"electron-forge" : " dist/electron-forge.js" ,
9
- "forge" : " dist/electron-forge.js"
9
+ "forge" : " dist/electron-forge.js" ,
10
+ "electron-forge-vscode-nix" : " script/vscode.sh"
10
11
},
11
12
"scripts" : {
12
13
"build" : " gulp build" ,
Original file line number Diff line number Diff line change
1
+ #! /usr/bin/env bash
2
+ DIR=" $( cd " $( dirname " ${BASH_SOURCE[0]} " ) " && pwd ) "
3
+
4
+ ARGS=$@
5
+ ARGS=${ARGS// / \~ \~ }
6
+
7
+ node $DIR /../electron-forge/dist/electron-forge-start --vscode --- \~ $ARGS \~
Original file line number Diff line number Diff line change @@ -22,6 +22,7 @@ import { start } from './api';
22
22
. option ( '-p, --app-path <path>' , "Override the path to the Electron app to launch (defaults to '.')" )
23
23
. option ( '-l, --enable-logging' , 'Enable advanced logging. This will log internal Electron things' )
24
24
. option ( '-n, --run-as-node' , 'Run the Electron app as a Node.JS script' )
25
+ . option ( '--vscode' , 'Used to enable arg transformation for debugging Electron through VSCode. Do not use yourself.' )
25
26
. action ( ( cwd ) => {
26
27
if ( ! cwd ) return ;
27
28
if ( path . isAbsolute ( cwd ) && fs . existsSync ( cwd ) ) {
@@ -47,6 +48,13 @@ import { start } from './api';
47
48
runAsNode : ! ! program . runAsNode ,
48
49
} ;
49
50
51
+ if ( program . vscode && appArgs ) {
52
+ appArgs = appArgs
53
+ // Args are in the format ~arg~ so we need to strip the "~"
54
+ . map ( arg => arg . substr ( 1 , arg . length - 2 ) )
55
+ . filter ( arg => arg . length > 0 ) ;
56
+ }
57
+
50
58
if ( program . appPath ) opts . appPath = program . appPath ;
51
59
if ( appArgs ) opts . args = appArgs ;
52
60
You can’t perform that action at this time.
0 commit comments