Skip to content

Commit

Permalink
remove indexer db with rm
Browse files Browse the repository at this point in the history
  • Loading branch information
karooolis committed Sep 25, 2024
1 parent 7c293cd commit c83037c
Showing 1 changed file with 5 additions and 7 deletions.
12 changes: 5 additions & 7 deletions packages/explorer/src/bin/explorer.ts
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
#!/usr/bin/env node
import { existsSync, watchFile } from "fs";
import fs from "fs";
import { readFile } from "fs/promises";
import path from "path";
import process from "process";
import { fileURLToPath } from "url";
import { anvil } from "viem/chains";
import yargs from "yargs";
import { ChildProcess, execSync, spawn } from "child_process";
import { ChildProcess, spawn } from "child_process";
import { validateChainId } from "../common";

const __filename = fileURLToPath(import.meta.url);
Expand Down Expand Up @@ -101,15 +101,13 @@ async function startExplorer() {
}
}

async function startStoreIndexer() {
function startStoreIndexer() {
if (chainId !== anvil.id) {
console.log("Skipping SQLite indexer for non-anvil chain ID", chainId);
return;
}

if (existsSync(indexerDatabasePath)) {
execSync(`shx rm -rf ${indexerDatabasePath}`);
}
fs.rmSync(indexerDatabasePath, { recursive: true, force: true });

console.log("Running SQLite indexer for anvil...");
indexerProcess = spawn("sh", ["node_modules/.bin/sqlite-indexer"], {
Expand Down Expand Up @@ -156,7 +154,7 @@ function watchWorldsJson() {
return;
}

watchFile(worldsFile, async () => {
fs.watchFile(worldsFile, async () => {
const newWorldAddress = await readWorldsJson();
if (worldAddress && worldAddress !== newWorldAddress) {
console.log("\nWorld address changed, restarting explorer...");
Expand Down

0 comments on commit c83037c

Please sign in to comment.