snowballtools-base/packages/backend/test/delete-db.ts
Nabarun Gogoi cfb4b4637c Add script to delete existing database (#44)
* Fix deployment creation time and hard coded title

* Add delete database script

* Use database file path from config file

---------

Co-authored-by: neeraj <neeraj.rtly@gmail.com>
2024-02-01 11:37:57 +05:30

22 lines
551 B
TypeScript

import * as fs from 'fs/promises';
import debug from 'debug';
import { getConfig } from '../src/utils';
import { Config } from '../src/config';
import { DEFAULT_CONFIG_FILE_PATH } from '../src/constants';
const log = debug('snowball:delete-database');
const deleteFile = async (filePath: string) => {
await fs.unlink(filePath);
log(`File ${filePath} has been deleted.`);
};
const main = async () => {
const config = await getConfig<Config>(DEFAULT_CONFIG_FILE_PATH);
deleteFile(config.database.dbPath);
};
main().catch(err => log(err));