@@ -2,15 +2,7 @@ import { series } from "async"
2
2
import { exec } from 'child_process'
3
3
import { readFileSync , writeFileSync , existsSync , mkdirSync } from 'fs'
4
4
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"
14
6
15
7
export default class ThesisLighthouse {
16
8
options
@@ -20,20 +12,10 @@ export default class ThesisLighthouse {
20
12
this . options = appOptions
21
13
this . execOptions = execOptions
22
14
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 ) } )
33
15
}
34
16
35
17
testURL ( urlToCheck , options = { } ) {
36
- const { commandToRun } = makeCommandFromURL ( urlToCheck , options )
18
+ const { commandToRun } = Command . make ( urlToCheck , options )
37
19
if ( options ?. consoleLog ?? true ) console . log ( `Running Test on ${ urlToCheck } ` )
38
20
39
21
series ( [
@@ -78,4 +60,16 @@ export default class ThesisLighthouse {
78
60
writeFileSync ( rawOutputFilename , JSON . stringify ( data ) , { flag : 'w' } )
79
61
return writeFileSync ( './out/scores.json' , newAccessibilityJSON , { flag : 'w' } )
80
62
}
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
+ }
81
75
}
0 commit comments