using regex to check for octicon

This commit is contained in:
aparna-ravindra
2021-08-16 16:48:34 +05:30
parent c090ea2f1b
commit 0d582377a8
+3 -3
View File
@@ -95,7 +95,7 @@ async function checkWorkflow(workflowPath: string, propertiesPath: string): Prom
workflowErrors.errors = res.errors.map(e => e.toString())
if (properties.iconName) {
if(!properties.iconName.startsWith("octicon ")) {
if(! /^octicon\s+/.test(properties.iconName)) {
try {
await fs.access(`../../icons/${properties.iconName}.svg`)
} catch (e) {
@@ -103,8 +103,8 @@ async function checkWorkflow(workflowPath: string, propertiesPath: string): Prom
}
}
else {
let iconName = properties.iconName.match(/octicon\s+(.*)/)
if(!iconName || !iconName[1] || iconName[1].length == 0) {
let iconName = properties.iconName.match(/^octicon\s+(.*)/)
if(!iconName || iconName[1].split(".")[0].length <= 0) {
workflowErrors.errors.push(`No icon named ${properties.iconName} found`)
}
}