mirror of
https://github.com/samsonjs/mit-license.git
synced 2026-04-27 15:07:42 +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
|
let errored = false
|
||||||
|
|
||||||
const users = fs.readdirSync('users')
|
const users = fs.readdirSync('users')
|
||||||
users.forEach(async user => {
|
users.forEach(async (user) => {
|
||||||
if (user.endsWith("json")) {
|
if (user.endsWith('json')) {
|
||||||
fs.readFile(path.join('users', user), "utf8", async (err, content) => {
|
fs.readFile(path.join('users', user), 'utf8', async (err, content) => {
|
||||||
if (err) {
|
if (err) {
|
||||||
errored = true
|
errored = true
|
||||||
console.error(`Unable to read ${user}`)
|
console.error(`Unable to read ${user}`)
|
||||||
} else {
|
} else {
|
||||||
try {
|
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) {
|
} catch (e) {
|
||||||
errored = true
|
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')
|
const themes = fs.readdirSync('themes')
|
||||||
themes.forEach(async theme => {
|
themes.forEach(async (theme) => {
|
||||||
if (theme.endsWith("css")) {
|
if (theme.endsWith('css')) {
|
||||||
fs.readFile(path.join('themes', theme), "utf8", async (err, content) => {
|
fs.readFile(path.join('themes', theme), 'utf8', async (err, content) => {
|
||||||
if (err) {
|
if (err) {
|
||||||
errored = true
|
errored = true
|
||||||
console.error(`Unable to read ${theme}`)
|
console.error(`Unable to read ${theme}`)
|
||||||
|
|
@ -39,11 +43,13 @@ themes.forEach(async theme => {
|
||||||
CSS.parse(content)
|
CSS.parse(content)
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
errored = true
|
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",
|
"url": "http://jesusurrutia.com",
|
||||||
"email": "jesus.urrutia@gmail.com",
|
"email": "jesus.urrutia@gmail.com",
|
||||||
"version": "html",
|
"version": "html",
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue