Skip to content

Commit

Permalink
feat(starter): windows implementation of the vscode debug command
Browse files Browse the repository at this point in the history
  • Loading branch information
MarshallOfSound authored and malept committed Apr 17, 2017
1 parent 1238dee commit 9cb7f42
Show file tree
Hide file tree
Showing 5 changed files with 39 additions and 4 deletions.
5 changes: 3 additions & 2 deletions README.md
Expand Up @@ -235,7 +235,7 @@ 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
```js
{
"type": "node",
"request": "launch",
Expand All @@ -248,6 +248,7 @@ good to go.
"runtimeArgs": [
"foo",
"bar"
]
],
"cwd": "${workspaceRoot}"
}
```
3 changes: 2 additions & 1 deletion package.json
Expand Up @@ -7,7 +7,8 @@
"bin": {
"electron-forge": "dist/electron-forge.js",
"forge": "dist/electron-forge.js",
"electron-forge-vscode-nix": "script/vscode.sh"
"electron-forge-vscode-nix": "script/vscode.sh",
"electron-forge-vscode-win": "script/vscode.cmd"
},
"scripts": {
"build": "gulp build",
Expand Down
9 changes: 9 additions & 0 deletions script/vscode.cmd
@@ -0,0 +1,9 @@
@echo off

SETLOCAL
SET FORGE_ARGS=%*

SET FORGE_ARGS=%FORGE_ARGS: =~ ~%
node "%~dp0/../../electron-forge/dist/electron-forge-start.js" --vscode --- ~%FORGE_ARGS%~

ENDLOCAL
2 changes: 1 addition & 1 deletion src/electron-forge-start.js
Expand Up @@ -49,8 +49,8 @@ import { start } from './api';
};

if (program.vscode && appArgs) {
// Args are in the format ~arg~ so we need to strip the "~"
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);
}
Expand Down
24 changes: 24 additions & 0 deletions test/fast/start_spec.js
Expand Up @@ -122,4 +122,28 @@ describe('start', () => {
enableLogging: true,
})).to.eventually.equal('child');
});

describe('cli', () => {
let argv;
beforeEach(() => {
argv = process.argv;
});

it('should remove all "~" from args when in VSCode debug mode', (done) => {
process.argv = ['--vscode', '---', '--foo', 'bar', 'this arg exists'];
proxyquire.noCallThru().load('../../src/electron-forge-start', {
'./api': {
start: (startOptions) => {
expect(startOptions.args).to.deep.equal(['--foo', 'bar', 'this arg exists']);
done();
return Promise.resolve();
},
},
});
});

afterEach(() => {
process.argv = argv;
});
});
});

0 comments on commit 9cb7f42

Please sign in to comment.