Skip to content

Commit

Permalink
#14: Simplify fs usage now that it's isolated
Browse files Browse the repository at this point in the history
  • Loading branch information
mtkennerly committed Dec 4, 2023
1 parent 5db68f4 commit 71fb37f
Showing 1 changed file with 1 addition and 15 deletions.
16 changes: 1 addition & 15 deletions src/reporters/jest.ts
Original file line number Diff line number Diff line change
@@ -1,24 +1,10 @@
import * as fsModule from "fs";
import * as fs from "fs";
import { Benchmark, benchmark } from '../index'
import { ExtensionLookup, handleExtraReports } from "./utils";

export const STATE_FILE = ".kelonio.state.json";

let fs: typeof fsModule;
let canUseFs = true;
try {
fs = require("fs");
} catch {
canUseFs = false;
}

export class BenchmarkFileState {
constructor() {
if (!canUseFs) {
throw new Error("Unable to access file system");
}
}

exists(): boolean {
return fs.existsSync(STATE_FILE);
}
Expand Down

0 comments on commit 71fb37f

Please sign in to comment.