mirror of
https://github.com/samsonjs/mit-license.git
synced 2026-04-15 12:55:47 +00:00
Catch invalid copyright info and fix broken files
This commit is contained in:
parent
46eb2eb45b
commit
549dbb9627
2 changed files with 17 additions and 11 deletions
26
test.js
26
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)
|
||||
|
|
|
|||
|
|
@ -1,5 +1,5 @@
|
|||
{
|
||||
"copyright": "",
|
||||
"copyright": "Jesús Urrutia",
|
||||
"url": "http://jesusurrutia.com",
|
||||
"email": "jesus.urrutia@gmail.com",
|
||||
"version": "html",
|
||||
|
|
|
|||
Loading…
Reference in a new issue