* Resolves script commands and determines if they should run in parallel * @param {string} commandName - Name of the command to resolve * @returns {Object} Resolved command object with commands array and parallel flag
(commandName)
| 85 | * @returns {Object} Resolved command object with commands array and parallel flag |
| 86 | */ |
| 87 | resolveScripts(commandName) { |
| 88 | if (this.resolvedScripts.has(commandName)) { |
| 89 | return this.resolvedScripts.get(commandName); |
| 90 | } |
| 91 | |
| 92 | let executableCommand = this.parsedScripts.get(commandName); |
| 93 | if (executableCommand === undefined) { |
| 94 | throw new Error(`Command "${commandName}" not found in scripts`); |
| 95 | } |
| 96 | |
| 97 | if (!executableCommand.startsWith("ui5nps") || executableCommand.startsWith("ui5nps-script")) { |
| 98 | this.resolvedScripts.set(commandName, { commandName, commands: [executableCommand], parallel: false }); |
| 99 | return this.resolvedScripts.get(commandName); |
| 100 | } |
| 101 | |
| 102 | const parts = executableCommand.trim().split(" ").filter(Boolean).slice(1); // Remove "ui5nps" or ui5nps-p part |
| 103 | const commands = []; |
| 104 | for (const part of parts) { |
| 105 | if (!this.parsedScripts.has(part)) { |
| 106 | throw new Error(`Referenced command "${part}" not found in scripts`); |
| 107 | } |
| 108 | |
| 109 | const parsedScript = this.parsedScripts.get(part); |
| 110 | |
| 111 | if (parsedScript && (parsedScript.startsWith("ui5nps") || parsedScript.startsWith("ui5nps-p"))) { |
| 112 | this.resolveScripts(part); |
| 113 | } |
| 114 | |
| 115 | commands.push(this.resolvedScripts.get(part) || { commandName: part, commands: [parsedScript], parallel: parsedScript.startsWith("ui5nps-p") }); |
| 116 | } |
| 117 | |
| 118 | |
| 119 | this.resolvedScripts.set(commandName, { commandName, commands, parallel: executableCommand.startsWith("ui5nps-p") }); |
| 120 | |
| 121 | return this.resolvedScripts.get(commandName); |
| 122 | } |
| 123 | |
| 124 | /** |
| 125 | * Loads and validates package-scripts file |
no test coverage detected