using set instead of array
This commit is contained in:
@@ -42,7 +42,7 @@ const propertiesSchema = {
|
|||||||
|
|
||||||
async function checkWorkflows(folders: string[]): Promise<WorkflowWithErrors[]> {
|
async function checkWorkflows(folders: string[]): Promise<WorkflowWithErrors[]> {
|
||||||
const result: WorkflowWithErrors[] = []
|
const result: WorkflowWithErrors[] = []
|
||||||
const workflow_template_names : string[] = []
|
const workflow_template_names = new Set()
|
||||||
for (const folder of folders) {
|
for (const folder of folders) {
|
||||||
const dir = await fs.readdir(folder, {
|
const dir = await fs.readdir(folder, {
|
||||||
withFileTypes: true,
|
withFileTypes: true,
|
||||||
@@ -56,13 +56,8 @@ async function checkWorkflows(folders: string[]): Promise<WorkflowWithErrors[]>
|
|||||||
const propertiesFilePath = join(folder, "properties", `${fileType}.properties.json`)
|
const propertiesFilePath = join(folder, "properties", `${fileType}.properties.json`)
|
||||||
|
|
||||||
const workflowWithErrors = await checkWorkflow(workflowFilePath, propertiesFilePath);
|
const workflowWithErrors = await checkWorkflow(workflowFilePath, propertiesFilePath);
|
||||||
if(workflowWithErrors.name) {
|
if(workflowWithErrors.name && workflow_template_names.size == workflow_template_names.add(workflowWithErrors.name).size) {
|
||||||
if(workflow_template_names.includes(workflowWithErrors.name)) {
|
workflowWithErrors.errors.push(`Workflow template name "${workflowWithErrors.name}" already exists`)
|
||||||
workflowWithErrors.errors.push(`Workflow template name "${workflowWithErrors.name}" already exists`)
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
workflow_template_names.push(workflowWithErrors.name)
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
if (workflowWithErrors.errors.length > 0) {
|
if (workflowWithErrors.errors.length > 0) {
|
||||||
result.push(workflowWithErrors)
|
result.push(workflowWithErrors)
|
||||||
|
|||||||
Reference in New Issue
Block a user