Skip to content

Commit c7b7cd8

Browse files
committed
Update application.class.js using Utilities and Command class
1 parent c8413be commit c7b7cd8

File tree

1 file changed

+14
-20
lines changed

1 file changed

+14
-20
lines changed

src/lib/application.class.js

Lines changed: 14 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -2,15 +2,7 @@ import { series } from "async"
22
import { exec } from 'child_process'
33
import { readFileSync, writeFileSync, existsSync, mkdirSync } from 'fs'
44
import { getCategoriesFlags, getCategoriesFromCategoriesFlags, getCurrentCategories } from "./categoriesHandlers.class.js"
5-
import { makeCommandFromURL } from "./commandHandlers.js"
6-
7-
Object.prototype.isEmpty = (obj) => {
8-
for (const prop in obj) (Object.hasOwn(obj, prop)) ? false : true
9-
}
10-
11-
Array.prototype.isEmpty = (arr) => {
12-
return (arr === undefined || arr.length === 0) ? false : true
13-
}
5+
import Command from "./commandHandlers.class.js"
146

157
export default class ThesisLighthouse {
168
options
@@ -20,20 +12,10 @@ export default class ThesisLighthouse {
2012
this.options = appOptions
2113
this.execOptions = execOptions
2214
this.urlList = urlList
23-
24-
if (this.options?.consoleLog) console.log(this.options)
25-
26-
const isOptionsCategories = getCategoriesFlags(this.options?.categories)
27-
const currentFlags = `${isOptionsCategories}\n\t--output json \n\t--disable-full-page-screenshot \n\t--chrome-flags="\n\t\t--no-sandbox \n\t\t--headless \n\t\t--disable-gpu"`
28-
29-
console.log(`ThesisLighthouse ${process.env.npm_package_version} - Thesis Example Code`)
30-
console.log(`Running with these flags: ${currentFlags}\n`)
31-
32-
this.urlList.forEach((url, index) => { this.testURL(url, this.options) })
3315
}
3416

3517
testURL(urlToCheck, options = {}) {
36-
const { commandToRun } = makeCommandFromURL(urlToCheck, options)
18+
const { commandToRun } = Command.make(urlToCheck, options)
3719
if (options?.consoleLog ?? true) console.log(`Running Test on ${urlToCheck}`)
3820

3921
series([
@@ -78,4 +60,16 @@ export default class ThesisLighthouse {
7860
writeFileSync(rawOutputFilename, JSON.stringify(data), { flag: 'w' })
7961
return writeFileSync('./out/scores.json', newAccessibilityJSON, { flag: 'w' })
8062
}
63+
64+
start() {
65+
if (this.options?.consoleLog) console.log(this.options)
66+
67+
const isOptionsCategories = getCategoriesFlags(this.options?.categories)
68+
const currentFlags = `${isOptionsCategories}\n\t--output json \n\t--disable-full-page-screenshot \n\t--chrome-flags="\n\t\t--no-sandbox \n\t\t--headless \n\t\t--disable-gpu"`
69+
70+
console.log(`ThesisLighthouse ${process.env.npm_package_version} - Thesis Example Code`)
71+
console.log(`Running with these flags: ${currentFlags}\n`)
72+
73+
this.urlList.forEach((url, index) => { this.testURL(url, this.options) })
74+
}
8175
}

0 commit comments

Comments
 (0)