Skip to content

Commit 0449316

Browse files
hakatashiclaude
andcommitted
fix(vocabwar): read gitignored state.json at runtime instead of importing
JSON import assertions make TypeScript resolve ./state.json statically, which fails in CI where the gitignored file does not exist. Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
1 parent fcbaa7b commit 0449316

1 file changed

Lines changed: 8 additions & 1 deletion

File tree

vocabwar/index.ts

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,14 @@ export default async ({eventClient, webClient: slack}: SlackInterface) => {
2525
ans: Map<string, string>;
2626
} = await (async () => {
2727
try {
28-
const savedState: any = (await import('./state.json', {with: {type: 'json'}})).default;
28+
// state.json is gitignored and may not exist, so it is read at runtime instead of being imported
29+
const savedStateText = await promisify(fs.readFile)(path.join(__dirname, 'state.json'), 'utf8');
30+
const savedState = JSON.parse(savedStateText) as {
31+
phase: string;
32+
theme: string | null;
33+
candidates: string[];
34+
ans: {[key: string]: string};
35+
};
2936
return {
3037
phase: savedState.phase,
3138
theme: savedState.theme || null,

0 commit comments

Comments
 (0)