mirror of
https://github.com/LukeHagar/better-auth.git
synced 2025-12-06 04:19:20 +00:00
chore: gitignore state.txt (#4543)
This commit is contained in:
2
.gitignore
vendored
2
.gitignore
vendored
@@ -197,3 +197,5 @@ android/
|
||||
|
||||
playwright-report/
|
||||
test-results/
|
||||
|
||||
state.txt
|
||||
|
||||
@@ -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);
|
||||
|
||||
@@ -1 +0,0 @@
|
||||
RUNNING
|
||||
@@ -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);
|
||||
|
||||
@@ -1 +0,0 @@
|
||||
IDLE
|
||||
25
packages/better-auth/src/test-utils/state.ts
Normal file
25
packages/better-auth/src/test-utils/state.ts
Normal 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 };
|
||||
}
|
||||
Reference in New Issue
Block a user