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 { spawn, ChildProcess } from "child_process";
|
||||||
|
import { existsSync } from "fs";
|
||||||
|
|
||||||
export interface StockfishLevel {
|
export interface StockfishLevel {
|
||||||
level: number;
|
level: number;
|
||||||
@@ -32,8 +33,7 @@ export class StockfishEngine {
|
|||||||
try {
|
try {
|
||||||
// Debian installs stockfish to /usr/games/stockfish
|
// Debian installs stockfish to /usr/games/stockfish
|
||||||
const sfBin = ["/usr/games/stockfish", "/usr/bin/stockfish", "stockfish"]
|
const sfBin = ["/usr/games/stockfish", "/usr/bin/stockfish", "stockfish"]
|
||||||
.find(p => { try { require("fs").accessSync(p); return true; } catch { return false; } })
|
.find(p => existsSync(p)) ?? "stockfish";
|
||||||
?? "stockfish";
|
|
||||||
|
|
||||||
this.process = spawn(sfBin, [], {
|
this.process = spawn(sfBin, [], {
|
||||||
stdio: ["pipe", "pipe", "pipe"],
|
stdio: ["pipe", "pipe", "pipe"],
|
||||||
|
|||||||
Reference in New Issue
Block a user