@@ -5,6 +5,7 @@ if (!existsSync('./src/urlList.js')) copyFileSync('./src/urlList.example', './sr
5
5
import { urlList , options , execOptions } from './src/urlList.js'
6
6
import { makeCommandFromURL } from './src/lib/commandHandlers.js'
7
7
import { getCategoriesFromCategoriesFlags , getCurrentCategories } from './src/lib/categoriesHandlers.js'
8
+ import { getCategoriesFlags } from "./src/lib/categoriesHandlers.js"
8
9
9
10
Object . prototype . isEmpty = ( obj ) => {
10
11
for ( const prop in obj )
@@ -22,8 +23,8 @@ const execResult = (err = null, out, outerr = null) => {
22
23
23
24
const data = JSON . parse ( out )
24
25
25
- const commandToRun = makeCommandFromURL ( data ?. requestedUrl , options )
26
- console . log ( `command stopped: ${ commandToRun } ` )
26
+ const { commandToRun } = makeCommandFromURL ( data ?. requestedUrl , options )
27
+ if ( options ?. consoleLog ?? true ) console . log ( `Stopped Test on ${ data ?. requestedUrl } ` )
27
28
28
29
const accessibilityScoresJSON = JSON . parse ( accessibilityScores )
29
30
const categoriesScoresObject = { }
@@ -44,7 +45,9 @@ const execResult = (err = null, out, outerr = null) => {
44
45
45
46
if ( ! existsSync ( './out/logs' ) ) mkdirSync ( './out/logs' )
46
47
47
- const logFileNameBasedOnUrl = data ?. requestedUrl . replace ( / ^ ( h t t p | h t t p s ) : \/ \/ ( w w w .| ) / g, '' ) . replaceAll ( "/" , "" ) . split ( '.' ) . reverse ( ) . join ( '.' )
48
+ const REGEX_HTTPS_HTTP = / ^ ( h t t p | h t t p s ) : \/ \/ ( w w w .| ) / g
49
+
50
+ const logFileNameBasedOnUrl = data ?. requestedUrl . replace ( REGEX_HTTPS_HTTP , '' ) . replaceAll ( "/" , "" ) . split ( '.' ) . reverse ( ) . join ( '.' )
48
51
const rawOutputFilename = `./out/logs/${ logFileNameBasedOnUrl } -${ optionCategories
49
52
. join ( '-' ) } -${ Date . now ( ) } .json`
50
53
@@ -53,9 +56,8 @@ const execResult = (err = null, out, outerr = null) => {
53
56
}
54
57
55
58
const testURL = ( urlToCheck , options = { } ) => {
56
- const commandToRun = makeCommandFromURL ( urlToCheck , options )
57
-
58
- console . log ( `running command: ${ commandToRun } ` )
59
+ const { commandToRun } = makeCommandFromURL ( urlToCheck , options )
60
+ if ( options ?. consoleLog ?? true ) console . log ( `Running Test on ${ urlToCheck } ` )
59
61
60
62
series ( [
61
63
( ) => exec ( commandToRun , execOptions , execResult ) ,
@@ -64,4 +66,14 @@ const testURL = (urlToCheck, options = {}) => {
64
66
] )
65
67
}
66
68
67
- urlList . forEach ( url => testURL ( url , options ) )
69
+ const main = ( urlList , options ) => {
70
+ const isOptionsCategories = getCategoriesFlags ( options ?. categories )
71
+ const currentFlags = `${ isOptionsCategories } --output json --disable-full-page-screenshot --chrome-flags="--no-sandbox --headless --disable-gpu"`
72
+
73
+ console . log ( `TLighthouse ${ process . env . npm_package_version } - Thesis Example Code` )
74
+ console . log ( `Running with these Flags: ${ currentFlags } \n` )
75
+
76
+ urlList . forEach ( ( url , index ) => { testURL ( url , options ) } )
77
+ }
78
+
79
+ main ( urlList , options )
0 commit comments