Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .github/workflows/updateCodeGov.yml
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,6 @@ jobs:

- name: Commit and push changes
run: |
git add ../codegov.json
git add codegov.json
git diff --staged --quiet || git commit -m "Auto-update JSON file"
git push
2 changes: 1 addition & 1 deletion config/updateCodeGov.js
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
const fs = require("fs").promises

Check failure on line 1 in config/updateCodeGov.js

View workflow job for this annotation

GitHub Actions / Run linter

Strings must use singlequote
const path = require('path')

// these will always stay constant
const CONFIG = {
testAgencyDirectory: path.resolve(__dirname, "../test-agency-indexes"),

Check failure on line 6 in config/updateCodeGov.js

View workflow job for this annotation

GitHub Actions / Run linter

Strings must use singlequote
agencyDirectory: path.resolve(__dirname, "../agency-indexes"),

Check failure on line 7 in config/updateCodeGov.js

View workflow job for this annotation

GitHub Actions / Run linter

Strings must use singlequote
outputFile: path.resolve(__dirname, "../codegov.json"),

Check failure on line 8 in config/updateCodeGov.js

View workflow job for this annotation

GitHub Actions / Run linter

Strings must use singlequote
regex: /^(.*?)-.*\.json$/
}

Expand All @@ -14,20 +14,20 @@
but that prove to be a disadvantage down the road */

// updates the codegov.json file with new data found from ./agency-indexes
async function updateCodeGov(isTesting = false) {

Check failure on line 17 in config/updateCodeGov.js

View workflow job for this annotation

GitHub Actions / Run linter

Expected to return a value at the end of async function 'updateCodeGov'
try {
const updatedJSON = {}
directoryPath = isTesting === true ? CONFIG.testAgencyDirectory : CONFIG.agencyDirectory

Check failure on line 20 in config/updateCodeGov.js

View workflow job for this annotation

GitHub Actions / Run linter

'directoryPath' is not defined

// read all files in the directory
const filenames = await fs.readdir(directoryPath)

Check failure on line 23 in config/updateCodeGov.js

View workflow job for this annotation

GitHub Actions / Run linter

'directoryPath' is not defined

// we know that the directory will only contain json files so dont need to check for non jsons
for (const file of filenames) {

Check failure on line 26 in config/updateCodeGov.js

View workflow job for this annotation

GitHub Actions / Run linter

iterators/generators require regenerator-runtime, which is too heavyweight for this guide to allow them. Separately, loops should be avoided in favor of array iterations
const filePath = path.join(directoryPath, file)

Check failure on line 27 in config/updateCodeGov.js

View workflow job for this annotation

GitHub Actions / Run linter

'directoryPath' is not defined

try {
const content = await fs.readFile(filePath, "utf-8")

Check failure on line 30 in config/updateCodeGov.js

View workflow job for this annotation

GitHub Actions / Run linter

Unexpected `await` inside a loop
const jsonData = JSON.parse(content)

// store the agency name only for readability in codegov.json
Expand All @@ -35,9 +35,9 @@
const agencyName = matches[1]

updatedJSON[agencyName] = jsonData
console.log(`✅ Successfully processed: ${file}`)

Check warning on line 38 in config/updateCodeGov.js

View workflow job for this annotation

GitHub Actions / Run linter

Unexpected console statement
} catch (error) {
console.error(`❌ Error processing file: ${file}`, error)

Check warning on line 40 in config/updateCodeGov.js

View workflow job for this annotation

GitHub Actions / Run linter

Unexpected console statement
}
}

Expand All @@ -47,8 +47,8 @@

return updatedJSON
} catch (error) {
console.error("❌ Failed to update codegov.json:", error)

Check warning on line 50 in config/updateCodeGov.js

View workflow job for this annotation

GitHub Actions / Run linter

Unexpected console statement
}
}

updateCodeGov()
updateCodeGov(isTesting = true)
Loading