Skip to content

Commit 309c5f7

Browse files
committed
fix: some improvements
1 parent 392ff77 commit 309c5f7

File tree

6 files changed

+8767
-1772
lines changed

6 files changed

+8767
-1772
lines changed

lib/api/list-actions.js

Lines changed: 10 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -7,19 +7,23 @@ const path = require('path');
77
const codeceptjsFactory = require('../model/codeceptjs-factory');
88
const { methodsOfObject } = require('codeceptjs/lib/utils');
99

10-
module.exports = (req, res) => {
10+
module.exports = (req, res) => {
1111
const { container } = codeceptjsFactory.getInstance();
1212
const docsWebApiFolderPath = path.join(path.dirname(require.resolve('codeceptjs')), '/../docs/webapi');
1313
const docFileList = [];
14-
fs.readdirSync(docsWebApiFolderPath).map(fileName => {
15-
docFileList.push(path.basename(fileName,'.mustache'));
16-
});
14+
try {
15+
fs.readdirSync(docsWebApiFolderPath).map(fileName => {
16+
docFileList.push(path.basename(fileName,'.mustache'));
17+
});
18+
} catch (e) {
19+
debug(`No documentation found due to ${e.message}`);
20+
}
1721
const helpers = container.helpers();
1822
const actions = {};
1923
for (const name in helpers) {
2024
const helper = helpers[name];
2125
methodsOfObject(helper).forEach((action) => {
22-
26+
2327
if(docFileList.includes(action)) {
2428
let filePath = path.join(docsWebApiFolderPath, action + '.mustache');
2529
let fn = helper[action].toString().replace(/\n/g,' ').replace(/\{.*\}/gm,'{}');
@@ -34,6 +38,6 @@ module.exports = (req, res) => {
3438

3539
});
3640
}
37-
41+
3842
res.send({ actions });
3943
};

lib/app.js

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
'use strict';
22

33
const path = require('path');
4-
const { BrowserWindow, app } = require('electron');
4+
const { BrowserWindow, app, shell } = require('electron');
55
const { getPort } = require('./config/env');
66

77
const NAME = 'CodeceptUI';
@@ -24,14 +24,14 @@ function createWindow() {
2424
const x = screenWidth - Math.max(width, 500);
2525
// Create the browser window.
2626
win = new BrowserWindow({
27-
width,
27+
width: screenWidth / 1.2,
2828
height: screenHeight,
2929
minWidth: 500,
3030
x,
3131
y: 0,
3232
title: NAME,
3333
autoHideMenuBar: true,
34-
icon: path.join(__dirname, '../build/icons/64x64.png'),
34+
icon: path.join(__dirname, '/build/icons/64x64.png'),
3535
webPreferences: {
3636
nodeIntegration: true,
3737
nodeIntegrationInWorker: true,
@@ -46,6 +46,11 @@ function createWindow() {
4646
win.on('closed', () => {
4747
win = null;
4848
});
49+
50+
win.webContents.setWindowOpenHandler(({ url }) => {
51+
// open url in a browser and prevent default
52+
shell.openExternal(url);
53+
});
4954
}
5055

5156
// Quit when all windows are closed.

lib/model/codeceptjs-factory.js

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -161,8 +161,10 @@ module.exports = new class CodeceptjsFactory {
161161
const helpersConfig = config.get('helpers');
162162

163163
for (const helperName in container.helpers()) {
164-
if (helpersConfig[helperName]) {
164+
try {
165165
container.helpers(helperName)._setConfig(helpersConfig[helperName]);
166+
} catch (e) {
167+
debug(`Cannot run _setConfig due to: ${e.message}`);
166168
}
167169
}
168170

0 commit comments

Comments
 (0)