Skip to content

Commit

Permalink
Fix how the modules were required to alleviate stress from the main p…
Browse files Browse the repository at this point in the history
…rocess
  • Loading branch information
thomasjbradley committed Nov 30, 2016
1 parent a8c34c9 commit 4f90c77
Show file tree
Hide file tree
Showing 32 changed files with 163 additions and 141 deletions.
7 changes: 7 additions & 0 deletions CHANGELOG.md
Expand Up @@ -14,6 +14,13 @@ Markbot adheres to [Semantic Versioning](http://semver.org/).
### Changed

- Move the `DEBUG` & the `serverPort` settings into the `package.json` file for simpler editing.
- Rewrote the `require()` statements to better work off the main process.
- Rewrote how the `markbot-main` module finds the main window to be more reliable.

### Fixed

- Fixed a bug in the screenshots where it didn’t tally which screenshots were completed properly.
- Added back the `asar` packing for the application.

---

Expand Down
2 changes: 1 addition & 1 deletion app/checks/all-files/html-unique.js
Expand Up @@ -3,7 +3,7 @@
const fs = require('fs');
const path = require('path');
const cheerio = require('cheerio');
const exists = require('../../file-exists');
const exists = require(__dirname + '/../../file-exists');

module.exports.find = function (folderPath, file, uniqueElems) {
const fullPath = path.resolve(folderPath + '/' + file.path);
Expand Down
5 changes: 2 additions & 3 deletions app/checks/all-files/task.js
Expand Up @@ -2,9 +2,8 @@
'use strict';

const path = require('path');
const main = require('electron').remote;
const markbotMain = main.require('./app/markbot-main');
const htmlUnique = main.require('./app/checks/all-files/html-unique');
const markbotMain = require('electron').remote.require('./app/markbot-main');
const htmlUnique = require(__dirname + '/checks/all-files/html-unique');

const group = taskDetails.group;
const id = 'html-unique';
Expand Down
4 changes: 2 additions & 2 deletions app/checks/css/best-practices.js
Expand Up @@ -2,8 +2,8 @@

const util = require('util');
const linter = require('stylelint');
const viewportChecker = require('./best-practices/viewport');
const markbotMain = require('../../markbot-main');
const markbotMain = require('electron').remote.require('./app/markbot-main');
const viewportChecker = require(__dirname + '/best-practices/viewport');

const shouldIncludeError = function (message, line, lines, fileContents) {
/* SVG overflow: hidden CSS */
Expand Down
2 changes: 1 addition & 1 deletion app/checks/css/properties.js
@@ -1,7 +1,7 @@
'use strict';

const css = require('css');
const markbotMain = require('../../markbot-main');
const markbotMain = require('electron').remote.require('./app/markbot-main');

const bypass = function (checkGroup, checkId, checkLabel) {
markbotMain.send('check-group:item-bypass', checkGroup, checkId, checkLabel, ['Skipped because of previous errors']);
Expand Down
13 changes: 6 additions & 7 deletions app/checks/css/task.js
Expand Up @@ -3,13 +3,12 @@

const fs = require('fs');
const path = require('path');
const main = require('electron').remote;
const markbotMain = main.require('./app/markbot-main');
const exists = main.require('./app/file-exists');
const validation = main.require('./app/checks/css/validation');
const bestPractices = main.require('./app/checks/css/best-practices');
const properties = main.require('./app/checks/css/properties');
const content = main.require('./app/checks/content');
const markbotMain = require('electron').remote.require('./app/markbot-main');
const exists = require(__dirname + '/file-exists');
const validation = require(__dirname + '/checks/css/validation');
const bestPractices = require(__dirname + '/checks/css/best-practices');
const properties = require(__dirname + '/checks/css/properties');
const content = require(__dirname + '/checks/content');

const group = taskDetails.group;
const file = taskDetails.options.file;
Expand Down
2 changes: 1 addition & 1 deletion app/checks/css/validation.js
Expand Up @@ -4,7 +4,7 @@ const path = require('path');
const util = require('util');
const exec = require('child_process').exec;
const xmlParser = require('xml2js').parseString;
const markbotMain = require('../../markbot-main');
const markbotMain = require('electron').remote.require('./app/markbot-main');

/**
* This function is mainly to work around Windows issues
Expand Down
17 changes: 8 additions & 9 deletions app/checks/files/task.js
@@ -1,18 +1,17 @@
(function () {
'use strict';

const main = require('electron').remote;
const fs = require('fs');
const path = require('path');
const util = require('util');
const calipers = main.require('calipers')('png', 'jpeg');
const exif = main.require('exif').ExifImage;
const pngitxt = main.require('png-itxt');
const merge = main.require('merge-objects');
const markbotMain = main.require('./app/markbot-main');
const stripPath = main.require('./app/strip-path');
const exists = main.require('./app/file-exists');
const listDir = main.require('./app/list-dir');
const calipers = require('calipers')('png', 'jpeg');
const exif = require('exif').ExifImage;
const pngitxt = require('png-itxt');
const merge = require('merge-objects');
const markbotMain = require('electron').remote.require('./app/markbot-main');
const stripPath = require(__dirname + '/strip-path');
const exists = require(__dirname + '/file-exists');
const listDir = require(__dirname + '/list-dir');

const group = taskDetails.group;
let totalFiles = 0;
Expand Down
2 changes: 0 additions & 2 deletions app/checks/functionality/injection.js
Expand Up @@ -100,12 +100,10 @@ const __MarkbotInjectedFunctions = {
},

pass: function () {
console.log('Pass!', __MarkbotInjectedFunctions.failed);
if (!__MarkbotInjectedFunctions.failed) __MarkbotInjectedFunctions.taskRunner.send(__MarkbotInjectedFunctions.passLabel);
},

fail: function (reason) {
console.log('Fail!');
__MarkbotInjectedFunctions.failed = true;
__MarkbotInjectedFunctions.taskRunner.send(__MarkbotInjectedFunctions.failLabel, reason);
},
Expand Down
13 changes: 6 additions & 7 deletions app/checks/functionality/task.js
Expand Up @@ -3,13 +3,12 @@

const fs = require('fs');
const path = require('path');
const main = require('electron').remote;
const ipcRenderer = require('electron').ipcRenderer;
const markbotMain = main.require('./app/markbot-main');
const fileExists = main.require('./app/file-exists');
const classify = main.require('./app/classify');
const webLoader = main.require('./app/web-loader');
const defaultsService = main.require('./app/checks/functionality/defaults-service');
const markbotMain = require('electron').remote.require('./app/markbot-main');
const fileExists = require(__dirname + '/file-exists');
const classify = require(__dirname + '/classify');
const webLoader = require(__dirname + '/web-loader');
const defaultsService = require(__dirname + '/checks/functionality/defaults-service');
const injectionJs = defaultsService.get('injection.js');

const group = taskDetails.group;
Expand Down Expand Up @@ -114,7 +113,7 @@
markbotMain.debug(...e);
});

webLoader.load(file.path, {}, function (theWindow) {
webLoader.load(taskRunnerId, file.path, {}, function (theWindow) {
win = theWindow;

if (file.tests) runTest(win, file.tests.shift(), currentTestIndex, listenerLabel);
Expand Down
4 changes: 2 additions & 2 deletions app/checks/git/commits.js
Expand Up @@ -4,8 +4,8 @@ const fs = require('fs');
const path = require('path');
const util = require('util');
const gitCommits = require('git-commits');
const exists = require('../../file-exists');
const markbotMain = require('../../markbot-main');
const exists = require(__dirname + '/../../file-exists');
const markbotMain = require('electron').remote.require('./app/markbot-main');

const matchesProfEmail = function (email, profEmails) {
return !profEmails.indexOf(email);
Expand Down
2 changes: 1 addition & 1 deletion app/checks/git/status.js
Expand Up @@ -4,7 +4,7 @@ const fs = require('fs');
const path = require('path');
const exec = require('child_process').exec;
const gitStatus = require('git-get-status');
const markbotMain = require('../../markbot-main');
const markbotMain = require('electron').remote.require('./app/markbot-main');

module.exports.check = function (fullPath, gitOpts, group, next) {
const allSynced = 'all-synced';
Expand Down
2 changes: 1 addition & 1 deletion app/checks/git/task-generator.js
@@ -1,6 +1,6 @@
'use strict';

let config = require('../../../config.json');
let config = require(__dirname + '/../../../config.json');

module.exports.generateTaskList = function (markbotFile) {
var tasks = [];
Expand Down
7 changes: 3 additions & 4 deletions app/checks/git/task.js
Expand Up @@ -2,10 +2,9 @@
'use strict';

const path = require('path');
const main = require('electron').remote;
const markbotMain = main.require('./app/markbot-main');
const commits = main.require('./app/checks/git/commits');
const status = main.require('./app/checks/git/status');
const markbotMain = require('electron').remote.require('./app/markbot-main');
const commits = require(__dirname + '/checks/git/commits');
const status = require(__dirname + '/checks/git/status');

const fullPath = path.resolve(taskDetails.cwd);

Expand Down
22 changes: 11 additions & 11 deletions app/checks/html/best-practices.js
@@ -1,17 +1,17 @@
'use strict';

const util = require('util');
const documentTagChecker = require('./best-practices/document-tags');
const lineBreakChecker = require('./best-practices/force-line-breaks');
const pTagCloseChecker = require('./best-practices/close-p-on-same-line');
const missingOptionalTagChecker = require('./best-practices/missing-optional-closing-tags');
const codeStyleChecker = require('./best-practices/code-style');
const emptyLineChecker = require('./best-practices/max-empty-lines');
const viewportChecker = require('./best-practices/viewport');
const doublespaceChecker = require('./best-practices/double-space');
const spaceBeforeCloseGTChecker = require('./best-practices/space-before-close-greater-than');
const indentationChecker = require('./best-practices/indentation');
const markbotMain = require('../../markbot-main');
const markbotMain = require('electron').remote.require('./app/markbot-main');
const documentTagChecker = require(__dirname + '/best-practices/document-tags');
const lineBreakChecker = require(__dirname + '/best-practices/force-line-breaks');
const pTagCloseChecker = require(__dirname + '/best-practices/close-p-on-same-line');
const missingOptionalTagChecker = require(__dirname + '/best-practices/missing-optional-closing-tags');
const codeStyleChecker = require(__dirname + '/best-practices/code-style');
const emptyLineChecker = require(__dirname + '/best-practices/max-empty-lines');
const viewportChecker = require(__dirname + '/best-practices/viewport');
const doublespaceChecker = require(__dirname + '/best-practices/double-space');
const spaceBeforeCloseGTChecker = require(__dirname + '/best-practices/space-before-close-greater-than');
const indentationChecker = require(__dirname + '/best-practices/indentation');

const bypass = function (checkGroup, checkId, checkLabel) {
markbotMain.send('check-group:item-bypass', checkGroup, checkId, checkLabel, ['Skipped because of previous errors']);
Expand Down
2 changes: 1 addition & 1 deletion app/checks/html/elements.js
Expand Up @@ -2,7 +2,7 @@

const util = require('util');
const cheerio = require('cheerio');
const markbotMain = require('../../markbot-main');
const markbotMain = require('electron').remote.require('./app/markbot-main');

const bypass = function (checkGroup, checkId, checkLabel) {
markbotMain.send('check-group:item-bypass', checkGroup, checkId, checkLabel, ['Skipped because of previous errors']);
Expand Down
2 changes: 1 addition & 1 deletion app/checks/html/outline.js
Expand Up @@ -2,7 +2,7 @@

const util = require('util');
const cheerio = require('cheerio');
const markbotMain = require('../../markbot-main');
const markbotMain = require('electron').remote.require('./app/markbot-main');

const getLevel = function (elem) {
return parseInt(elem.name.slice(1), 10);
Expand Down
15 changes: 7 additions & 8 deletions app/checks/html/task.js
Expand Up @@ -3,14 +3,13 @@

const fs = require('fs');
const path = require('path');
const main = require('electron').remote;
const markbotMain = main.require('./app/markbot-main');
const exists = main.require('./app/file-exists');
const validation = main.require('./app/checks/html/validation');
const bestPractices = main.require('./app/checks/html/best-practices');
const outline = main.require('./app/checks/html/outline');
const elements = main.require('./app/checks/html/elements');
const content = main.require('./app/checks/content');
const markbotMain = require('electron').remote.require('./app/markbot-main');
const exists = require(__dirname + '/file-exists');
const validation = require(__dirname + '/checks/html/validation');
const bestPractices = require(__dirname + '/checks/html/best-practices');
const outline = require(__dirname + '/checks/html/outline');
const elements = require(__dirname + '/checks/html/elements');
const content = require(__dirname + '/checks/content');

const group = taskDetails.group;
const file = taskDetails.options.file;
Expand Down
2 changes: 1 addition & 1 deletion app/checks/html/validation.js
Expand Up @@ -3,7 +3,7 @@
const util = require('util');
const path = require('path');
const exec = require('child_process').exec;
const markbotMain = require('../../markbot-main');
const markbotMain = require('electron').remote.require('./app/markbot-main');

const escapeShell = function (cmd) {
return '"' + cmd.replace(/(["'$`\\])/g, '\\$1') + '"';
Expand Down
4 changes: 2 additions & 2 deletions app/checks/javascript/best-practices.js
Expand Up @@ -2,8 +2,8 @@

const util = require('util');
const linter = require('eslint').linter;
const linterConfig = require('./best-practices/eslint.json');
const markbotMain = require('../../markbot-main');
const linterConfig = require(__dirname + '/best-practices/eslint.json');
const markbotMain = require('electron').remote.require('./app/markbot-main');

const bypass = function (checkGroup, checkId, checkLabel) {
markbotMain.send('check-group:item-bypass', checkGroup, checkId, checkLabel, ['Skipped because of previous errors']);
Expand Down
11 changes: 5 additions & 6 deletions app/checks/javascript/task.js
Expand Up @@ -3,12 +3,11 @@

const fs = require('fs');
const path = require('path');
const main = require('electron').remote;
const markbotMain = main.require('./app/markbot-main');
const exists = main.require('./app/file-exists');
const validation = main.require('./app/checks/javascript/validation');
const bestPractices = main.require('./app/checks/javascript/best-practices');
const content = main.require('./app/checks/content');
const markbotMain = require('electron').remote.require('./app/markbot-main');
const exists = require(__dirname + '/file-exists');
const validation = require(__dirname + '/checks/javascript/validation');
const bestPractices = require(__dirname + '/checks/javascript/best-practices');
const content = require(__dirname + '/checks/content');

const group = taskDetails.group;
const file = taskDetails.options.file;
Expand Down
4 changes: 2 additions & 2 deletions app/checks/javascript/validation.js
Expand Up @@ -3,8 +3,8 @@
const util = require('util');
const path = require('path');
const linter = require('eslint').linter;
const linterConfig = require('./validation/eslint.json');
const markbotMain = require('../../markbot-main');
const linterConfig = require(__dirname + '/validation/eslint.json');
const markbotMain = require('electron').remote.require('./app/markbot-main');

const bypass = function (checkGroup, checkId, checkLabel) {
markbotMain.send('check-group:item-bypass', checkGroup, checkId, checkLabel, ['Skipped because of previous errors']);
Expand Down
3 changes: 1 addition & 2 deletions app/checks/live-website/task.js
Expand Up @@ -2,8 +2,7 @@
'use strict';

const https = require('https');
const main = require('electron').remote;
const markbotMain = main.require('./app/markbot-main');
const markbotMain = require('electron').remote.require('./app/markbot-main');

const group = taskDetails.group;
const repo = taskDetails.options.repo;
Expand Down
13 changes: 6 additions & 7 deletions app/checks/naming-conventions/task.js
Expand Up @@ -2,16 +2,15 @@
'use strict';

const path = require('path');
const main = require('electron').remote;
const markbotMain = main.require('./app/markbot-main');
const listDir = main.require('./app/list-dir');
const stripPath = main.require('./app/strip-path');
const markbotMain = require('electron').remote.require('./app/markbot-main');
const listDir = require(__dirname + '/list-dir');
const stripPath = require(__dirname + '/strip-path');

const extsBlackList = main.require('./app/checks/naming-conventions/extension-blacklist.json');
const extsBlackList = require(__dirname + '/checks/naming-conventions/extension-blacklist.json');
const extsBlackListSearch = `(${extsBlackList.join('|')})$`;
const fileBlackList = main.require('./app/checks/naming-conventions/file-blacklist.json');
const fileBlackList = require(__dirname + '/checks/naming-conventions/file-blacklist.json');
const fileBlackListSearch = `(${fileBlackList.join('|')})`;
const pathsWhiteList = main.require('./app/checks/naming-conventions/path-whitelist.json');
const pathsWhiteList = require(__dirname + '/checks/naming-conventions/path-whitelist.json');
const pathsWhiteListSearch = `^(${pathsWhiteList.join('|').replace(/\./ig, '\.')})`;

const fullPath = path.resolve(taskDetails.cwd);
Expand Down
19 changes: 9 additions & 10 deletions app/checks/performance/task.js
@@ -1,22 +1,21 @@
(function () {
'use strict';

const main = require('electron').remote;
const path = require('path');
const merge = main.require('merge-objects');
const webcoach = main.require('webcoach');
const merge = require('merge-objects');
const webcoach = require('webcoach');
const ipcRenderer = require('electron').ipcRenderer;
const exists = main.require('./app/file-exists');
const markbotMain = main.require('./app/markbot-main');
const webLoader = main.require('./app/web-loader');
const webServer = main.require('./app/web-server');
const adviceIgnoreIds = main.require('./app/checks/performance/ignore-advice-ids.json');
const markbotMain = require('electron').remote.require('./app/markbot-main');
const exists = require(__dirname + '/file-exists');
const webLoader = require(__dirname + '/web-loader');
const webServer = require(__dirname + '/web-server');
const adviceIgnoreIds = require(__dirname + '/checks/performance/ignore-advice-ids.json');

const group = taskDetails.group;
const fullPath = taskDetails.cwd;

let totalFiles = 0;

console.log(markbotMain);
const perfDefaults = {
speed: 'WIFI',
budget: {
Expand Down Expand Up @@ -179,7 +178,7 @@
return done();
}

webLoader.load(file.path, {speed: perf.speed}, function (theWindow, theHar) {
webLoader.load(taskRunnerId, file.path, {speed: perf.speed}, function (theWindow, theHar) {
win = theWindow;
har = theHar;

Expand Down
2 changes: 1 addition & 1 deletion app/checks/screenshots/naming-service.js
Expand Up @@ -2,7 +2,7 @@

const path = require('path');
const is = require('electron-is');
const classify = require('../../classify');
const classify = require(__dirname + '/../../classify');

const SCREENSHOT_PREFIX = 'markbot';
const REFERENCE_SCREENSHOT_FOLDER = 'screenshots';
Expand Down

0 comments on commit 4f90c77

Please sign in to comment.