(outputsDir: string)
| 459 | } |
| 460 | |
| 461 | private async collectAndValidateOutputsAsync(outputsDir: string): Promise<void> { |
| 462 | const files = await fs.readdir(outputsDir); |
| 463 | |
| 464 | for (const outputId of files) { |
| 465 | if (!(outputId in this.outputById)) { |
| 466 | const newOutput = new BuildStepOutput(this.ctx.global, { |
| 467 | id: outputId, |
| 468 | stepDisplayName: this.displayName, |
| 469 | required: false, |
| 470 | }); |
| 471 | this.outputById[outputId] = newOutput; |
| 472 | } |
| 473 | |
| 474 | const file = path.join(outputsDir, outputId); |
| 475 | const rawContents = await fs.readFile(file, 'utf-8'); |
| 476 | const decodedContents = Buffer.from(rawContents, 'base64').toString('utf-8'); |
| 477 | this.outputById[outputId].set(decodedContents); |
| 478 | } |
| 479 | |
| 480 | const nonSetRequiredOutputIds: string[] = []; |
| 481 | for (const output of Object.values(this.outputById)) { |
| 482 | try { |
| 483 | const value = output.value; |
| 484 | this.ctx.logger.debug(`Output parameter "${output.id}" is set to "${value}"`); |
| 485 | } catch (err) { |
| 486 | this.ctx.logger.debug({ err }, `Getting value for output parameter "${output.id}" failed.`); |
| 487 | nonSetRequiredOutputIds.push(output.id); |
| 488 | } |
| 489 | } |
| 490 | if (nonSetRequiredOutputIds.length > 0) { |
| 491 | const idsString = nonSetRequiredOutputIds.map(i => `"${i}"`).join(', '); |
| 492 | throw new BuildStepRuntimeError(`Some required outputs have not been set: ${idsString}`, { |
| 493 | metadata: { ids: nonSetRequiredOutputIds }, |
| 494 | }); |
| 495 | } |
| 496 | } |
| 497 | |
| 498 | private async collectAndUpdateEnvsAsync(envsDir: string): Promise<void> { |
| 499 | const filenames = await fs.readdir(envsDir); |
no test coverage detected