diff --git a/tools/cli/bundlers/web-bundler.js b/tools/cli/bundlers/web-bundler.js index e1a565d3..730c8987 100644 --- a/tools/cli/bundlers/web-bundler.js +++ b/tools/cli/bundlers/web-bundler.js @@ -697,16 +697,25 @@ class WebBundler { removeSkippedWorkflowCommands(agentXml, skippedWorkflows) { let modifiedXml = agentXml; - // For each skipped workflow, find and remove the corresponding command + // For each skipped workflow, find and remove menu items and commands for (const workflowPath of skippedWorkflows) { - // Match: ... // Need to escape special regex characters in the path const escapedPath = workflowPath.replaceAll(/[.*+?^${}()|[\]\\]/g, String.raw`\$&`); - // Pattern to match the command line with this workflow - const pattern = new RegExp(`\\s*]*>.*?\\s*`, 'gs'); + // Pattern 1: Remove tags with workflow attribute + // Match: ... + const itemWorkflowPattern = new RegExp(`\\s*]*workflow="[^"]*${escapedPath}"[^>]*>.*?\\s*`, 'gs'); + modifiedXml = modifiedXml.replace(itemWorkflowPattern, ''); - modifiedXml = modifiedXml.replace(pattern, ''); + // Pattern 2: Remove tags with run-workflow attribute + // Match: ... + const itemRunWorkflowPattern = new RegExp(`\\s*]*run-workflow="[^"]*${escapedPath}"[^>]*>.*?\\s*`, 'gs'); + modifiedXml = modifiedXml.replace(itemRunWorkflowPattern, ''); + + // Pattern 3: Remove tags with run-workflow attribute (legacy) + // Match: ... + const cPattern = new RegExp(`\\s*]*run-workflow="[^"]*${escapedPath}"[^>]*>.*?\\s*`, 'gs'); + modifiedXml = modifiedXml.replace(cPattern, ''); } return modifiedXml;