| 147 | } |
| 148 | |
| 149 | function getExpressionValue(option: string, isSet: boolean, word: string, value: string) { |
| 150 | const operations: Record<string, Function> = { |
| 151 | '-': (isSet: boolean, word: string, value: string) => isSet ? value : word, |
| 152 | '+': (isSet: boolean, word: string, value: string) => isSet ? word : value, |
| 153 | }; |
| 154 | |
| 155 | return operations[option](isSet, word, value).replace(/^['"]|['"]$/g, ''); // remove quotes from start and end of the string |
| 156 | } |
| 157 | |
| 158 | function replaceVariables(dockerfile: Dockerfile, buildArgs: Record<string, string>, baseImageEnv: Record<string, string>, globalBuildxPlatformArgs: Record<string, string> = {}, str: string, stage: { from?: From; instructions: Instruction[] }, beforeInstructionIndex: number) { |
| 159 | return [...str.matchAll(argumentExpression)] |