Skip to content

Commit acc62d9

Browse files
author
Maxime GRIS
committed
feat/ VSCode : add Debugging config for man process (#465) + Karma
1 parent 92eb8ec commit acc62d9

File tree

5 files changed

+73
-9
lines changed

5 files changed

+73
-9
lines changed

.vscode/launch.json

+36
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
{
2+
// Use IntelliSense to learn about possible attributes.
3+
// Hover to view descriptions of existing attributes.
4+
// For more information, visit: https://go.microsoft.com/fwlink/?linkid=830387
5+
"version": "0.2.0",
6+
"configurations": [
7+
{
8+
"name": "Electron Main Renderer",
9+
"type": "node",
10+
"request": "launch",
11+
"protocol": "inspector",
12+
// Prelaunch task compiles main.ts for Electron & starts Angular dev server.
13+
"preLaunchTask": "Build.All",
14+
"cwd": "${workspaceFolder}",
15+
"runtimeExecutable": "${workspaceFolder}/node_modules/.bin/electron",
16+
"runtimeArgs": [
17+
"--serve",
18+
".",
19+
"--remote-debugging-port=9222"
20+
],
21+
"windows": {
22+
"runtimeExecutable": "${workspaceFolder}/node_modules/.bin/electron.cmd"
23+
}
24+
}, {
25+
"name": "Karma Attach Chrome",
26+
"type": "chrome",
27+
"request": "attach",
28+
"port": 9222,
29+
"webRoot": "${workspaceFolder}/",
30+
"sourceMaps": true,
31+
"timeout": 30000,
32+
"trace": true
33+
}
34+
35+
]
36+
}

.vscode/tasks.json

+27
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
{
2+
"version": "2.0.0",
3+
"tasks": [
4+
{
5+
"label": "Build.All",
6+
"type": "shell",
7+
"command": "npm run electron:serve-tsc && ng serve",
8+
"isBackground": true,
9+
"group": {
10+
"kind": "build",
11+
"isDefault": true
12+
},
13+
"problemMatcher": {
14+
"owner": "typescript",
15+
"source": "ts",
16+
"applyTo": "closedDocuments",
17+
"fileLocation": ["relative", "${cwd}"],
18+
"pattern": "$tsc",
19+
"background": {
20+
"activeOnStart": true,
21+
"beginsPattern": "^.*",
22+
"endsPattern": "^.*Compiled successfully.*"
23+
}
24+
}
25+
}
26+
]
27+
}

main.ts

+5-4
Original file line numberDiff line numberDiff line change
@@ -24,10 +24,15 @@ function createWindow(): BrowserWindow {
2424
});
2525

2626
if (serve) {
27+
28+
require('devtron').install();
29+
win.webContents.openDevTools();
30+
2731
require('electron-reload')(__dirname, {
2832
electron: require(`${__dirname}/node_modules/electron`)
2933
});
3034
win.loadURL('http://localhost:4200');
35+
3136
} else {
3237
win.loadURL(url.format({
3338
pathname: path.join(__dirname, 'dist/index.html'),
@@ -36,10 +41,6 @@ function createWindow(): BrowserWindow {
3641
}));
3742
}
3843

39-
if (serve) {
40-
win.webContents.openDevTools();
41-
}
42-
4344
// Emitted when the window is closed.
4445
win.on('closed', () => {
4546
// Dereference the window object, usually you would store window

package.json

+4-2
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,8 @@
3333
"electron:linux": "npm run build:prod && electron-builder build --linux",
3434
"electron:windows": "npm run build:prod && electron-builder build --windows",
3535
"electron:mac": "npm run build:prod && electron-builder build --mac",
36-
"test": "ng test",
36+
"test": "ng test --watch=false",
37+
"test:watch": "ng test",
3738
"e2e": "npm run build:prod && cross-env TS_NODE_PROJECT='e2e/tsconfig.e2e.json' mocha --timeout 300000 --require ts-node/register e2e/**/*.e2e.ts",
3839
"version": "conventional-changelog -i CHANGELOG.md -s -r 0 && git add CHANGELOG.md",
3940
"lint": "ng lint"
@@ -65,6 +66,7 @@
6566
"conventional-changelog-cli": "2.0.32",
6667
"core-js": "3.6.5",
6768
"cross-env": "7.0.2",
69+
"devtron": "1.4.0",
6870
"electron": "8.2.3",
6971
"electron-builder": "22.5.1",
7072
"electron-reload": "1.5.0",
@@ -81,8 +83,8 @@
8183
"npm-run-all": "4.1.5",
8284
"rxjs": "6.5.5",
8385
"spectron": "10.0.1",
84-
"tslib": "1.11.1",
8586
"ts-node": "8.9.1",
87+
"tslib": "1.11.1",
8688
"typescript": "3.8.3",
8789
"wait-on": "4.0.2",
8890
"webdriver-manager": "12.1.7",

src/karma.conf.js

+1-3
Original file line numberDiff line numberDiff line change
@@ -24,9 +24,7 @@ module.exports = function (config) {
2424
port: 9876,
2525
colors: true,
2626
logLevel: config.LOG_INFO,
27-
autoWatch: true,
2827
browsers: ['AngularElectron'],
29-
singleRun: true,
3028
customLaunchers: {
3129
AngularElectron: {
3230
base: 'Electron',
@@ -43,4 +41,4 @@ module.exports = function (config) {
4341
}
4442
}
4543
});
46-
};
44+
};

0 commit comments

Comments
 (0)