From 549dbb9627d25feb5750ea6f8736174c41f2a9a7 Mon Sep 17 00:00:00 2001 From: Richie Bendall Date: Fri, 31 May 2019 23:19:18 +1200 Subject: [PATCH] Catch invalid copyright info and fix broken files --- test.js | 26 ++++++++++++++++---------- users/jesusurrutia.json | 2 +- 2 files changed, 17 insertions(+), 11 deletions(-) diff --git a/test.js b/test.js index b1272c09..7f21472c 100644 --- a/test.js +++ b/test.js @@ -6,18 +6,22 @@ const CSS = require('css') let errored = false const users = fs.readdirSync('users') -users.forEach(async user => { - if (user.endsWith("json")) { - fs.readFile(path.join('users', user), "utf8", async (err, content) => { +users.forEach(async (user) => { + if (user.endsWith('json')) { + fs.readFile(path.join('users', user), 'utf8', async (err, content) => { if (err) { errored = true console.error(`Unable to read ${user}`) } else { try { - JSON.parse(content) + const u = JSON.parse(content) + if (!u.locked && !u.copyright) { + errored = true + console.error(`Copyright not specified in ${user} (${e})`) + } } catch (e) { errored = true - console.error(`Invalid JSON in file: ${user} (${e})`) + console.error(`Invalid JSON in ${user} (${e})`) } } }) @@ -28,9 +32,9 @@ users.forEach(async user => { }) const themes = fs.readdirSync('themes') -themes.forEach(async theme => { - if (theme.endsWith("css")) { - fs.readFile(path.join('themes', theme), "utf8", async (err, content) => { +themes.forEach(async (theme) => { + if (theme.endsWith('css')) { + fs.readFile(path.join('themes', theme), 'utf8', async (err, content) => { if (err) { errored = true console.error(`Unable to read ${theme}`) @@ -39,11 +43,13 @@ themes.forEach(async theme => { CSS.parse(content) } catch (e) { errored = true - console.error(`Invalid CSS in file: ${theme} (${e})`) + console.error(`Invalid CSS in ${theme} (${e})`) } } }) } }) -if (errored) process.exit(1) +setTimeout(() => { + if (errored) process.exit(1) +}, 500) diff --git a/users/jesusurrutia.json b/users/jesusurrutia.json index d05ab4cb..65fbeca9 100644 --- a/users/jesusurrutia.json +++ b/users/jesusurrutia.json @@ -1,5 +1,5 @@ { - "copyright": "", + "copyright": "Jesús Urrutia", "url": "http://jesusurrutia.com", "email": "jesus.urrutia@gmail.com", "version": "html",