fix: use existsSync instead of require(fs) in ESM module
This commit is contained in:
@@ -1,4 +1,5 @@
|
||||
import { spawn, ChildProcess } from "child_process";
|
||||
import { existsSync } from "fs";
|
||||
|
||||
export interface StockfishLevel {
|
||||
level: number;
|
||||
@@ -32,8 +33,7 @@ export class StockfishEngine {
|
||||
try {
|
||||
// Debian installs stockfish to /usr/games/stockfish
|
||||
const sfBin = ["/usr/games/stockfish", "/usr/bin/stockfish", "stockfish"]
|
||||
.find(p => { try { require("fs").accessSync(p); return true; } catch { return false; } })
|
||||
?? "stockfish";
|
||||
.find(p => existsSync(p)) ?? "stockfish";
|
||||
|
||||
this.process = spawn(sfBin, [], {
|
||||
stdio: ["pipe", "pipe", "pipe"],
|
||||
|
||||
Reference in New Issue
Block a user