Skip to content

Commit 4ff0c4b

Browse files
authored
Feature Checkdir for application.class.js (#21)
Feature `Checkdir` for `application.class.js`
2 parents 73db3d8 + 0b634cf commit 4ff0c4b

File tree

1 file changed

+10
-5
lines changed

1 file changed

+10
-5
lines changed

src/lib/application.class.js

Lines changed: 10 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@ export default class ThesisLighthouse {
4242

4343
const newAccessibilityJSON = this.#produceNewJSON(data, accessibilityScores)
4444

45-
this.#checkDir()
45+
this.#checkDir([`${this.#outputDir}`, `${this.#outputDir}logs`])
4646
const rawOutputFilename = this.#createFileName(data?.requestedUrl)
4747

4848
writeFileSync(rawOutputFilename, JSON.stringify(data), { flag: 'w' })
@@ -81,17 +81,22 @@ export default class ThesisLighthouse {
8181
return (!existsSync(location)) ? readFileSync(backup) : readFileSync(location)
8282
}
8383

84-
#checkDir = () => {
85-
this.#makeDirIfNotExists(`${this.#outputDir}`)
86-
this.#makeDirIfNotExists(`${this.#outputDir}logs`)
84+
#checkDir = (directories) => {
85+
switch (typeof directories) {
86+
case "object":
87+
directories.forEach(directory => this.#makeDirIfNotExists(directory))
88+
break;
89+
case "string":
90+
this.#makeDirIfNotExists(directories)
91+
break;
92+
}
8793
}
8894

8995
#makeDirIfNotExists = (location) => {
9096
if (!existsSync(location)) mkdirSync(location)
9197
}
9298

9399
start = () => {
94-
95100
const isOptionsCategories = getCategoriesFlags(this.options?.categories)
96101
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"`
97102

0 commit comments

Comments
 (0)