chore: gitignore state.txt (#4543)

This commit is contained in:
Fraol Lemecha
2025-09-09 20:01:11 +03:00
committed by GitHub
parent abfc48d2aa
commit bd0ce60165
6 changed files with 31 additions and 28 deletions

2
.gitignore vendored
View File

@@ -197,3 +197,5 @@ android/
playwright-report/
test-results/
state.txt

View File

@@ -1,14 +1,3 @@
import * as fs from "fs";
import path from "path";
import { makeTestState } from "../../../test-utils/state";
export type State = "IDLE" | "RUNNING";
export const stateFilePath = path.join(__dirname, "./state.txt");
export function getState(): State {
return fs.readFileSync(stateFilePath, "utf-8").split("\n")[0].trim() as State;
}
export function setState(state: State) {
fs.writeFileSync(stateFilePath, state, "utf-8");
}
export const { stateFilePath, getState, setState } = makeTestState(__dirname);

View File

@@ -1,14 +1,3 @@
import * as fs from "fs";
import path from "path";
import { makeTestState } from "../../../test-utils/state";
export type State = "IDLE" | "RUNNING";
export const stateFilePath = path.join(__dirname, "./state.txt");
export function getState(): State {
return fs.readFileSync(stateFilePath, "utf-8").split("\n")[0].trim() as State;
}
export function setState(state: State) {
fs.writeFileSync(stateFilePath, state, "utf-8");
}
export const { stateFilePath, getState, setState } = makeTestState(__dirname);

View File

@@ -0,0 +1,25 @@
import * as fs from "fs";
import path from "path";
export type State = "IDLE" | "RUNNING";
export function makeTestState(dirname: string) {
const stateFilePath = path.join(dirname, "./state.txt");
function getState(): State {
try {
return fs
.readFileSync(stateFilePath, "utf-8")
.split("\n")[0]
.trim() as State;
} catch {
return "IDLE";
}
}
function setState(state: State) {
fs.writeFileSync(stateFilePath, state, "utf-8");
}
return { stateFilePath, getState, setState };
}