| 105 | ); |
| 106 | |
| 107 | const getWorkDir = async (fixtureName: string, fixtureSource: string) => { |
| 108 | // Always copy source to a random tmp dir |
| 109 | const tempDir = await realpath( |
| 110 | await mkdtemp(join(tmpdir(), `fixture-${fixtureName}-`)) |
| 111 | ); |
| 112 | await cp(fixtureSource, tempDir, { recursive: true }); |
| 113 | |
| 114 | // When USE_DEBUG_DIR is true, lambda output goes to debug/{fixtureName} |
| 115 | // Otherwise, lambda output goes to the same temp dir |
| 116 | let lambdaOutputDir = tempDir; |
| 117 | if (USE_DEBUG_DIR) { |
| 118 | lambdaOutputDir = join(DEBUG_DIR, fixtureName); |
| 119 | await rm(lambdaOutputDir, { recursive: true, force: true }); |
| 120 | await mkdir(lambdaOutputDir, { recursive: true }); |
| 121 | } |
| 122 | |
| 123 | return { workDir: tempDir, lambdaOutputDir }; |
| 124 | }; |
| 125 | |
| 126 | describe('successful builds', async () => { |
| 127 | const fixtures = await readdir(join(__dirname, 'fixtures')); |