mirror of
https://github.com/awesome-selfhosted/awesome-selfhosted.git
synced 2024-12-28 16:54:22 +00:00
Fix bugs in tests.
This commit is contained in:
parent
7dd2189850
commit
a81bd71bb3
@ -42,7 +42,7 @@ function split(text) {
|
|||||||
|
|
||||||
// All entries should match this pattern. If matches pattern returns true.
|
// All entries should match this pattern. If matches pattern returns true.
|
||||||
function findPattern(text) {
|
function findPattern(text) {
|
||||||
const patt = /^\s{0,2}-\s\[.*?\]\(.*?\) (`⚠` )?- .{0,249}?\.( \(\[(Demo|Source Code|Clients)\]\([^)]*\)(, \[(Source Code|Clients)\]\([^)]*\))?(, \[(Source Code|Clients)\]\([^)]*\))*\))? \`.*?\` \`.*?\`$/;
|
const patt = /^\s{0,2}-\s\[.*?\]\(.*?\) (`⚠` )?- .{0,249}?\.( \(\[(Demo|Source Code|Clients)\]\([^)\]]*\)(, \[(Source Code|Clients)\]\([^)\]]*\))?(, \[(Source Code|Clients)\]\([^)\]]*\))*\))? \`.*?\` \`.*?\`$/;
|
||||||
if (patt.test(text) === true) {
|
if (patt.test(text) === true) {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
@ -55,10 +55,10 @@ function parseLicense(md) {
|
|||||||
return patt.exec(md)[1]
|
return patt.exec(md)[1]
|
||||||
}
|
}
|
||||||
|
|
||||||
//Tests '- [Name](http://homepage/)'
|
//Test '- [Name](http://homepage/)'
|
||||||
function testMainLink(text) {
|
function testMainLink(text) {
|
||||||
let testA = /(^ {0,2}- \[.*?\]\(.*\))(?=.?-? ?\w)/;
|
let testA = /(^ {0,2}- \[.*?\]\(.*\))(?=.?-? ?\w)/;
|
||||||
const testA1 = /(- \[.*?\]?\(?.*?\)?)( .*$)/;
|
const testA1 = /(- \W?\w*\W{0,2}.*?\)?)( .*$)/;
|
||||||
if (!testA.test(text)) {
|
if (!testA.test(text)) {
|
||||||
let a1 = testA1.exec(text)[2];
|
let a1 = testA1.exec(text)[2];
|
||||||
return chalk.red(text.replace(a1, ''))
|
return chalk.red(text.replace(a1, ''))
|
||||||
@ -66,10 +66,10 @@ function testMainLink(text) {
|
|||||||
return chalk.green(testA.exec(text)[1])
|
return chalk.green(testA.exec(text)[1])
|
||||||
}
|
}
|
||||||
|
|
||||||
//Tests '`⚠` - Short description, less than 250 characters.'
|
//Test '`⚠` - Short description, less than 250 characters.'
|
||||||
function testDescription(text) {
|
function testDescription(text) {
|
||||||
const testB = /( - .*\. )(?:(\(?\[?|\`))/;
|
const testB = /( - .*\. )(?:(\(?\[?|\`))/;
|
||||||
const testA1 = /(- \[.*?\]?\(?.*?\)?)( .*$)/;
|
const testA1 = /(- \W?\w*\W{0,2}.*?\)?)( .*$)/;
|
||||||
const testB2 = /((\(\[|\`).*$)/;
|
const testB2 = /((\(\[|\`).*$)/;
|
||||||
if (!testB.test(text)) {
|
if (!testB.test(text)) {
|
||||||
let b1 = testA1.exec(text)[1];
|
let b1 = testA1.exec(text)[1];
|
||||||
@ -82,14 +82,13 @@ function testDescription(text) {
|
|||||||
//If present, tests '([Demo](http://url.to/demo), [Source Code](http://url.of/source/code), [Clients](https://url.to/list/of/related/clients-or-apps))'
|
//If present, tests '([Demo](http://url.to/demo), [Source Code](http://url.of/source/code), [Clients](https://url.to/list/of/related/clients-or-apps))'
|
||||||
function testSrcDemCli(text) {
|
function testSrcDemCli(text) {
|
||||||
let testC = text.search(/\(\[|\)\,|\)\)/);
|
let testC = text.search(/\(\[|\)\,|\)\)/);
|
||||||
let testD = /(?<=\w. )(\(\[(Demo|Source Code|Clients)\]\([^)]*\)(, \[(Source Code|Clients)\]\([^)]*\))?(, \[(Source Code|Clients)\]\([^)]*\))*\))(?= \`?)/;
|
let testD = /(?<=\w. )(\(\[(Demo|Source Code|Clients)\]\([^)\]]*\)(, \[(Source Code|Clients)\]\([^)\]]*\))?(, \[(Source Code|Clients)\]\([^)\]]*\))*\))(?= \`?)/;
|
||||||
const testD1 = /(^.*\.)(?= )/;
|
const testD1 = /(^- \W[a-zA-Z0-9-_ ]*\W{0,2}http[^\[]*)(?<= )/;
|
||||||
const testD2 = /(\`.*\` \`.*\`$)/;
|
const testD2 = /(\`.*\` \`.*\`$)/;
|
||||||
if ((testC > -1) && (!testD.test(text))) {
|
if ((testC > -1) && (!testD.test(text))) {
|
||||||
let d1 = testD1.exec(text)[1];
|
let d1 = testD1.exec(text)[1];
|
||||||
let d2 = testD2.exec(text)[1];
|
let d2 = testD2.exec(text)[1];
|
||||||
|
return chalk.red(text.replace(d1, '').replace(d2, ''))
|
||||||
return chalk.red(text.replace(d1+' ', '').replace(d2, ''))
|
|
||||||
} else if (testC > -1) {
|
} else if (testC > -1) {
|
||||||
return chalk.green(testD.exec(text)[1])
|
return chalk.green(testD.exec(text)[1])
|
||||||
}
|
}
|
||||||
@ -123,7 +122,8 @@ function testLicense(md) {
|
|||||||
let pass = true;
|
let pass = true;
|
||||||
let lFailed = []
|
let lFailed = []
|
||||||
let lPassed = []
|
let lPassed = []
|
||||||
const regex = /.*\`(.*)\` \`.*\`$/;
|
const regex = /.*\`(.*)\` .*$/;
|
||||||
|
try {
|
||||||
for (l of regex.exec(md)[1].split("/")) {
|
for (l of regex.exec(md)[1].split("/")) {
|
||||||
if (!licenses.has(l)) {
|
if (!licenses.has(l)) {
|
||||||
pass = false;
|
pass = false;
|
||||||
@ -131,6 +131,16 @@ function testLicense(md) {
|
|||||||
}
|
}
|
||||||
lFailed.push(l)
|
lFailed.push(l)
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
catch(err) {
|
||||||
|
console.log(chalk.yellow("Error in License syntax, license not checked against list."))
|
||||||
|
return [false, "", ""]
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
return [pass, lFailed, lPassed]
|
return [pass, lFailed, lPassed]
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -187,7 +197,7 @@ function entryErrorCheck() {
|
|||||||
if (!findPattern(e.raw)) {
|
if (!findPattern(e.raw)) {
|
||||||
e.highlight = findError(e.raw);
|
e.highlight = findError(e.raw);
|
||||||
e.pass = false;
|
e.pass = false;
|
||||||
console.log(`${e.highlight}`)
|
console.log(e.highlight)
|
||||||
}
|
}
|
||||||
e.licenseTest = testLicense(e.raw);
|
e.licenseTest = testLicense(e.raw);
|
||||||
if (!e.licenseTest) {
|
if (!e.licenseTest) {
|
||||||
|
Loading…
Reference in New Issue
Block a user