Skip to content

Commit cc69686

Browse files
committed
fix: Clear generated env directory before shim generation
1 parent 83a5cd8 commit cc69686

File tree

3 files changed

+32
-26
lines changed

3 files changed

+32
-26
lines changed

package-lock.json

Lines changed: 24 additions & 24 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

packages/backend-function/src/function_env_type_generator.test.ts

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import { describe, it, mock } from 'node:test';
1+
import { beforeEach, describe, it, mock } from 'node:test';
22
import fs from 'fs';
33
import fsp from 'fs/promises';
44
import { FunctionEnvironmentTypeGenerator } from './function_env_type_generator.js';
@@ -7,6 +7,9 @@ import { pathToFileURL } from 'url';
77
import path from 'path';
88

99
void describe('FunctionEnvironmentTypeGenerator', () => {
10+
beforeEach(() => {
11+
resetFactoryCount();
12+
});
1013
void it('generates a type definition file', () => {
1114
const fsOpenSyncMock = mock.method(fs, 'openSync');
1215
const fsWriteFileSyncMock = mock.method(fs, 'writeFileSync', () => null);
@@ -122,4 +125,7 @@ void describe('FunctionEnvironmentTypeGenerator', () => {
122125
fsExistsSyncMock.mock.restore();
123126
fsRmSyncMock.mock.restore();
124127
});
128+
const resetFactoryCount = () => {
129+
FunctionEnvironmentTypeGenerator.isEnvDirectoryInitialized = false;
130+
};
125131
});

packages/backend-function/src/function_env_type_generator.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ import { EOL } from 'os';
88
*/
99
export class FunctionEnvironmentTypeGenerator {
1010
// Using this to ensure directory is cleared once
11-
private static isEnvDirectoryInitialized = false;
11+
static isEnvDirectoryInitialized = false;
1212
private readonly header =
1313
'// This file is auto-generated by Amplify. Edits will be overwritten.';
1414

0 commit comments

Comments
 (0)