Skip to content

Commit

Permalink
feat/ VSCode : add Debugging config for man process (#465) + Karma
Browse files Browse the repository at this point in the history
  • Loading branch information
Maxime GRIS committed May 2, 2020
1 parent 92eb8ec commit acc62d9
Show file tree
Hide file tree
Showing 5 changed files with 73 additions and 9 deletions.
36 changes: 36 additions & 0 deletions .vscode/launch.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
{
// Use IntelliSense to learn about possible attributes.
// Hover to view descriptions of existing attributes.
// For more information, visit: https://go.microsoft.com/fwlink/?linkid=830387
"version": "0.2.0",
"configurations": [
{
"name": "Electron Main Renderer",
"type": "node",
"request": "launch",
"protocol": "inspector",
// Prelaunch task compiles main.ts for Electron & starts Angular dev server.
"preLaunchTask": "Build.All",
"cwd": "${workspaceFolder}",
"runtimeExecutable": "${workspaceFolder}/node_modules/.bin/electron",
"runtimeArgs": [
"--serve",
".",
"--remote-debugging-port=9222"
],
"windows": {
"runtimeExecutable": "${workspaceFolder}/node_modules/.bin/electron.cmd"
}
}, {
"name": "Karma Attach Chrome",
"type": "chrome",
"request": "attach",
"port": 9222,
"webRoot": "${workspaceFolder}/",
"sourceMaps": true,
"timeout": 30000,
"trace": true
}

]
}
27 changes: 27 additions & 0 deletions .vscode/tasks.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
{
"version": "2.0.0",
"tasks": [
{
"label": "Build.All",
"type": "shell",
"command": "npm run electron:serve-tsc && ng serve",
"isBackground": true,
"group": {
"kind": "build",
"isDefault": true
},
"problemMatcher": {
"owner": "typescript",
"source": "ts",
"applyTo": "closedDocuments",
"fileLocation": ["relative", "${cwd}"],
"pattern": "$tsc",
"background": {
"activeOnStart": true,
"beginsPattern": "^.*",
"endsPattern": "^.*Compiled successfully.*"
}
}
}
]
}
9 changes: 5 additions & 4 deletions main.ts
Original file line number Diff line number Diff line change
Expand Up @@ -24,10 +24,15 @@ function createWindow(): BrowserWindow {
});

if (serve) {

require('devtron').install();
win.webContents.openDevTools();

require('electron-reload')(__dirname, {
electron: require(`${__dirname}/node_modules/electron`)
});
win.loadURL('http://localhost:4200');

} else {
win.loadURL(url.format({
pathname: path.join(__dirname, 'dist/index.html'),
Expand All @@ -36,10 +41,6 @@ function createWindow(): BrowserWindow {
}));
}

if (serve) {
win.webContents.openDevTools();
}

// Emitted when the window is closed.
win.on('closed', () => {
// Dereference the window object, usually you would store window
Expand Down
6 changes: 4 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,8 @@
"electron:linux": "npm run build:prod && electron-builder build --linux",
"electron:windows": "npm run build:prod && electron-builder build --windows",
"electron:mac": "npm run build:prod && electron-builder build --mac",
"test": "ng test",
"test": "ng test --watch=false",
"test:watch": "ng test",
"e2e": "npm run build:prod && cross-env TS_NODE_PROJECT='e2e/tsconfig.e2e.json' mocha --timeout 300000 --require ts-node/register e2e/**/*.e2e.ts",
"version": "conventional-changelog -i CHANGELOG.md -s -r 0 && git add CHANGELOG.md",
"lint": "ng lint"
Expand Down Expand Up @@ -65,6 +66,7 @@
"conventional-changelog-cli": "2.0.32",
"core-js": "3.6.5",
"cross-env": "7.0.2",
"devtron": "1.4.0",
"electron": "8.2.3",
"electron-builder": "22.5.1",
"electron-reload": "1.5.0",
Expand All @@ -81,8 +83,8 @@
"npm-run-all": "4.1.5",
"rxjs": "6.5.5",
"spectron": "10.0.1",
"tslib": "1.11.1",
"ts-node": "8.9.1",
"tslib": "1.11.1",
"typescript": "3.8.3",
"wait-on": "4.0.2",
"webdriver-manager": "12.1.7",
Expand Down
4 changes: 1 addition & 3 deletions src/karma.conf.js
Original file line number Diff line number Diff line change
Expand Up @@ -24,9 +24,7 @@ module.exports = function (config) {
port: 9876,
colors: true,
logLevel: config.LOG_INFO,
autoWatch: true,
browsers: ['AngularElectron'],
singleRun: true,
customLaunchers: {
AngularElectron: {
base: 'Electron',
Expand All @@ -43,4 +41,4 @@ module.exports = function (config) {
}
}
});
};
};

0 comments on commit acc62d9

Please sign in to comment.