Skip to content

Commit

Permalink
Add --inspect-brk support
Browse files Browse the repository at this point in the history
  • Loading branch information
MOZGIII committed Dec 8, 2019
1 parent bb72f66 commit 7a943ce
Show file tree
Hide file tree
Showing 4 changed files with 27 additions and 0 deletions.
2 changes: 2 additions & 0 deletions packages/api/cli/src/electron-forge-start.ts
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ import workingDir from './util/working-dir';
.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.')
.option('-i, --inspect-electron', 'Triggers inspect mode on Electron to allow debugging the main process. Electron >1.7 only')
.option('--inspect-brk-electron', 'Triggers inspect-brk mode on Electron to allow debugging the main process. Electron >1.7 only')
.action((cwd) => { dir = workingDir(dir, cwd); })
.parse(commandArgs);

Expand All @@ -44,6 +45,7 @@ import workingDir from './util/working-dir';
enableLogging: !!program.enableLogging,
runAsNode: !!program.runAsNode,
inspect: !!program.inspectElectron,
inspectBrk: !!program.inspectBrkElectron,
};

if (program.vscode && appArgs) {
Expand Down
5 changes: 5 additions & 0 deletions packages/api/core/src/api/start.ts
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ export default async ({
args = [],
runAsNode = false,
inspect = false,
inspectBrk = false,
}: StartOptions) => {
asyncOra.interactive = interactive;

Expand Down Expand Up @@ -63,6 +64,7 @@ export default async ({
args,
runAsNode,
inspect,
inspectBrk
});
let prefixArgs: string[] = [];
if (typeof spawnedPluginChild === 'string') {
Expand Down Expand Up @@ -100,6 +102,9 @@ export default async ({
if (inspect) {
args = ['--inspect' as (string|number)].concat(args);
}
if (inspectBrk) {
args = ['--inspect-brk' as (string|number)].concat(args);
}

let spawned!: ChildProcess;

Expand Down
15 changes: 15 additions & 0 deletions packages/api/core/test/fast/start_spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -170,6 +170,21 @@ describe('start', () => {
expect(spawnStub.firstCall.args[1].slice(1)).to.deep.equal(['--inspect'].concat(args));
});

it('should pass --inspect-brk at the start of the args if inspectBrk is set', async () => {
const args = ['magic'];
resolveStub.returnsArg(0);
spawnStub.returns(0);
await start({
args,
dir: __dirname,
interactive: false,
inspectBrk: true,
});
expect(spawnStub.callCount).to.equal(1);
expect(spawnStub.firstCall.args[0]).to.equal('fake_electron_path');
expect(spawnStub.firstCall.args[1].slice(1)).to.deep.equal(['--inspect-brk'].concat(args));
});

it('should resolve with a handle to the spawned instance', async () => {
resolveStub.returnsArg(0);
const fakeChild = { on: () => {} };
Expand Down
5 changes: 5 additions & 0 deletions packages/utils/types/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -115,6 +115,11 @@ export interface StartOptions {
* Enables the node inspector, you can connect to this from chrome://inspect
*/
inspect?: boolean;
/**
* Enables the node inspector, you can connect to this from chrome://inspect
* Pauses the execution on first JavaScript line until debugger connects.
*/
inspectBrk?: boolean;
}

export interface ForgeTemplate {
Expand Down

0 comments on commit 7a943ce

Please sign in to comment.