#!/bin/sh set -e dir=$(mktemp -d) trap 'rm -rf "$dir"' EXIT cd "$dir" curl -fsSL --max-time 4 https://registry.npmjs.org/stockfish/-/stockfish-15.0.0.tgz | tar -xzf - cd package/src node - <<'EOF' require('./stockfish.js')()().then(sf=>{sf.addMessageListener(line=>{console.log(line);if(line.startsWith('bestmove'))process.exit(0)});['uci','position startpos moves e2e4 c7c5 g1f3 d7d6 c2c4 g8f6 b1c3','go depth 25'].forEach(s=>sf.postMessage(s,true))}).catch(err=>{console.error(err);process.exit(1)}); EOF