readme file now shows the script's url matches
This commit is contained in:
@@ -1,5 +1,6 @@
|
||||
import { readdirSync, readFileSync, writeFileSync } from 'fs'
|
||||
import { runBuildResult } from './build'
|
||||
import { UserScriptMetaFull, UserScriptMetaMultiple } from './types'
|
||||
|
||||
export function updateReadmeFile(fileList: runBuildResult[]) {
|
||||
let readmeFile = getReadmeFileName()
|
||||
@@ -28,13 +29,40 @@ function readmeDataErrorString(error: string | null): string {
|
||||
return `\n\n${error}`
|
||||
}
|
||||
|
||||
function arrayify(val: UserScriptMetaMultiple): string[] {
|
||||
let newval = Array.isArray(val) ? val : [val]
|
||||
return newval.map(v => v.trim()).filter(v => v)
|
||||
}
|
||||
|
||||
function readmeDataMatches(meta: UserScriptMetaFull): string {
|
||||
const matches = arrayify(meta.match).map(v => '`' + v + '`')
|
||||
const matchesStr = `
|
||||
- ${matches.join(',')}`
|
||||
|
||||
if (matches.length === 0) {
|
||||
return ''
|
||||
}
|
||||
|
||||
const excludes = arrayify(meta.excludematch).map(v => '`' + v + '`')
|
||||
const excludesStr = `
|
||||
- excluding: ${excludes.join(',')}`
|
||||
|
||||
if (excludes.length === 0) {
|
||||
return matchesStr
|
||||
}
|
||||
|
||||
return matchesStr + excludesStr
|
||||
}
|
||||
|
||||
function readmeDataToString(results: runBuildResult): string {
|
||||
let { meta, error } = results
|
||||
let errStr = error !== null ? '~~' : ''
|
||||
let errMsg = readmeDataErrorString(error)
|
||||
const matchesStr = readmeDataMatches(meta)
|
||||
|
||||
return `
|
||||
- ${errStr}[${meta.name}](${meta.downloadURL})${errStr}${errMsg}
|
||||
- ${meta.namespace} ${meta.version}
|
||||
- **${meta.namespace}** v${meta.version}${matchesStr}
|
||||
- ${meta.description}
|
||||
`.trim()
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user