-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Create
Lighthouse Accessibility Thesis Program
(#1)
Create `Lighthouse Accessibility Thesis Program`
- Loading branch information
Showing
7 changed files
with
1,719 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
node_modules/ | ||
|
||
/out/ | ||
/src/urlList.js |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
import { existsSync, rmSync } from 'fs'; | ||
|
||
const cleanDirectory = () => { | ||
if (!existsSync('./out/')) return console.error(`failed: dir out not exist`) | ||
rmSync('./out/', { recursive: true }) | ||
console.log(`complete: dir out has been deleted`) | ||
} | ||
|
||
cleanDirectory() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
import { series } from 'async'; | ||
import { exec } from 'child_process'; | ||
import { readFileSync, writeFileSync, existsSync, mkdirSync, copyFileSync } from 'fs'; | ||
if (!existsSync('./src/urlList.js')) copyFileSync('./src/urlList.example', './src/urlList.js') | ||
import { urlList } from './src/urlList.js'; | ||
|
||
const execResult = (err = null, out, outerr = null) => { | ||
let accessibilityScores = (!existsSync('./out/scores.json')) ? readFileSync('./src/scores.json') : readFileSync('./out/scores.json') | ||
|
||
const data = JSON.parse(out); | ||
const accessibilityScoresJSON = JSON.parse(accessibilityScores) | ||
const URLaccessibilityScoreResult = data?.categories?.accessibility?.score | ||
accessibilityScoresJSON[data.requestedUrl] = URLaccessibilityScoreResult | ||
const newAccessibilityJSON = JSON.stringify(accessibilityScoresJSON) | ||
if (!existsSync('./out/')) mkdirSync('./out/') | ||
return writeFileSync('./out/scores.json', newAccessibilityJSON, { flag: 'w' }) | ||
} | ||
|
||
const testURL = (urlToCheck) => { | ||
const commandToRun = `lighthouse ${urlToCheck} --only-categories=accessibility --output json` | ||
|
||
series([ | ||
() => exec(commandToRun, execResult) | ||
]) | ||
} | ||
|
||
urlList.forEach(url => testURL(url)) |
Oops, something went wrong.