-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
ENSRainbow: Add purge command (#285)
Co-authored-by: Tomek Kopacki <[email protected]> Co-authored-by: lightwalker.eth <[email protected]>
- Loading branch information
1 parent
3cb4466
commit 1a4c1ab
Showing
4 changed files
with
66 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
import { rm } from "fs/promises"; | ||
import { logger } from "../utils/logger"; | ||
|
||
export interface PurgeCommandOptions { | ||
dataDir: string; | ||
} | ||
|
||
export async function purgeCommand(options: PurgeCommandOptions): Promise<void> { | ||
const { dataDir } = options; | ||
|
||
try { | ||
logger.info(`Removing database directory at ${dataDir}...`); | ||
await rm(dataDir, { recursive: true, force: true }); | ||
logger.info("Database directory removed successfully."); | ||
} catch (error) { | ||
const errorMessage = error instanceof Error ? error.message : 'Unknown error'; | ||
|
||
logger.error(`Failed to remove database directory: ${errorMessage}`); | ||
throw error; | ||
} | ||
} |