Skip to content
Permalink
Browse files

feat(starter): provide an executable to start forge in a vscode debug…

…ger compatible way

Currently only on darwin and linux, win32 implemenation to come
  • Loading branch information
MarshallOfSound authored and malept committed Apr 16, 2017
1 parent 2e00a9c commit 1238dee524ecc533d8937ce511c749cc1bd002f9
Showing with 40 additions and 1 deletion.
  1. +23 −0 README.md
  2. +2 −1 package.json
  3. +7 −0 script/vscode.sh
  4. +8 −0 src/electron-forge-start.js
@@ -228,3 +228,26 @@ You must export a Function that returns a Promise. Your function will be called
* tag - The value of `--tag`

You should use `ora` to indicate your publish progress.

## Debugging your application through VS Code

Debugging your Electron main process through VS Code is ridiculously
easy with Forge. Simply add this as a launch config in VSCode and you're
good to go.

```json
{
"type": "node",
"request": "launch",
"name": "Electron Main",
"runtimeExecutable": "${workspaceRoot}/node_modules/.bin/electron-forge-vscode-nix",
"windows": {
"runtimeExecutable": "${workspaceRoot}/node_modules/.bin/electron-forge-vscode-win.cmd"
},
// runtimeArgs will be passed directly to your Electron application
"runtimeArgs": [
"foo",
"bar"
]
}
```
@@ -6,7 +6,8 @@
"main": "dist/api/index.js",
"bin": {
"electron-forge": "dist/electron-forge.js",
"forge": "dist/electron-forge.js"
"forge": "dist/electron-forge.js",
"electron-forge-vscode-nix": "script/vscode.sh"
},
"scripts": {
"build": "gulp build",
@@ -0,0 +1,7 @@
#!/usr/bin/env bash
DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"

ARGS=$@
ARGS=${ARGS// /\~ \~}

node $DIR/../electron-forge/dist/electron-forge-start --vscode --- \~$ARGS\~
@@ -22,6 +22,7 @@ import { start } from './api';
.option('-p, --app-path <path>', "Override the path to the Electron app to launch (defaults to '.')")
.option('-l, --enable-logging', 'Enable advanced logging. This will log internal Electron things')
.option('-n, --run-as-node', 'Run the Electron app as a Node.JS script')
.option('--vscode', 'Used to enable arg transformation for debugging Electron through VSCode. Do not use yourself.')
.action((cwd) => {
if (!cwd) return;
if (path.isAbsolute(cwd) && fs.existsSync(cwd)) {
@@ -47,6 +48,13 @@ import { start } from './api';
runAsNode: !!program.runAsNode,
};

if (program.vscode && appArgs) {
appArgs = appArgs
// Args are in the format ~arg~ so we need to strip the "~"
.map(arg => arg.substr(1, arg.length - 2))
.filter(arg => arg.length > 0);
}

if (program.appPath) opts.appPath = program.appPath;
if (appArgs) opts.args = appArgs;

0 comments on commit 1238dee

Please sign in to comment.
You can’t perform that action at this time.