Skip to content

Commit

Permalink
👷 Added gh-action for checking if images exist
Browse files Browse the repository at this point in the history
  • Loading branch information
AnotherFoxGuy committed Apr 4, 2021
1 parent 0dcdb72 commit 435d398
Show file tree
Hide file tree
Showing 2 changed files with 51 additions and 0 deletions.
17 changes: 17 additions & 0 deletions .github/workflows/check-json.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
name: Check for missing images

on:
push:
branches:
- master
pull_request:

jobs:
check:
runs-on: ubuntu-latest

steps:
- uses: actions/[email protected]

- name: Check if images exist
run: node ./tools/CI/check-jsons.js
34 changes: 34 additions & 0 deletions tools/CI/check-jsons.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
#!/usr/bin/env node

const fs = require("fs")
const pwd = process.cwd()


let TileDataRaw = fs.readFileSync(`${pwd}/data/resources/data/TileData.json`, "utf8")
let TileData = JSON.parse(TileDataRaw)

let failed = 0

TileData.forEach(e => {
let ex = fs.existsSync(`${pwd}/data/${e.tiles.fileName}`)
if (!ex){
console.error(`File does not exist: ${e.tiles.fileName}`)
failed = 1
}
})

let UIDataRaw = fs.readFileSync(`${pwd}/data/resources/data/UIData.json`, "utf8")
let UIData = JSON.parse(UIDataRaw)

for (const [_, ent] of Object.entries(UIData)) {
for (const [_, image] of Object.entries(ent)){
let ex = fs.existsSync(`${pwd}/data/${image}`)
if (!ex){
console.error(`File does not exist: ${image}`)
failed = 1
}
}
}


process.exit(failed)

0 comments on commit 435d398

Please sign in to comment.