Format with prettier. Use screen mode for invitation import - dialog mode is broken.
This commit is contained in:
@@ -1,35 +1,40 @@
|
||||
import fs from 'fs/promises';
|
||||
import fs from "fs/promises";
|
||||
|
||||
/**
|
||||
* Remove all the databases without the use of external tools
|
||||
* TODO: Fix the ts linking issue here. Should just be adding this as a dir in tsconfig.json
|
||||
*/
|
||||
const rmDbs = async (dry = false) => {
|
||||
// First, we need to find all the database base files
|
||||
// These end in either .db.sqlite, .sqlite, .db
|
||||
// Get all the files in the current directory
|
||||
const files = await fs.readdir('./');
|
||||
// First, we need to find all the database base files
|
||||
// These end in either .db.sqlite, .sqlite, .db
|
||||
// Get all the files in the current directory
|
||||
const files = await fs.readdir("./");
|
||||
|
||||
// Filter out the files that end in .db.sqlite, .sqlite, .db
|
||||
const dbFiles = files.filter(file => file.endsWith('.db.sqlite') || file.endsWith('.sqlite') || file.endsWith('.db'));
|
||||
|
||||
// We need to remove all the files
|
||||
await deleteFiles(dbFiles, dry);
|
||||
}
|
||||
// Filter out the files that end in .db.sqlite, .sqlite, .db
|
||||
const dbFiles = files.filter(
|
||||
(file) =>
|
||||
file.endsWith(".db.sqlite") ||
|
||||
file.endsWith(".sqlite") ||
|
||||
file.endsWith(".db"),
|
||||
);
|
||||
|
||||
// We need to remove all the files
|
||||
await deleteFiles(dbFiles, dry);
|
||||
};
|
||||
|
||||
const deleteFiles = async (files: string[], dry = false) => {
|
||||
if (dry) {
|
||||
console.log('Dry run, would delete:', files);
|
||||
return
|
||||
}
|
||||
if (dry) {
|
||||
console.log("Dry run, would delete:", files);
|
||||
return;
|
||||
}
|
||||
|
||||
await Promise.all(files.map(file => fs.rm(file)));
|
||||
console.log('All databases removed');
|
||||
}
|
||||
await Promise.all(files.map((file) => fs.rm(file)));
|
||||
console.log("All databases removed");
|
||||
};
|
||||
|
||||
// Read args
|
||||
const args = process.argv.slice(2);
|
||||
const dry = args.includes('--dry');
|
||||
const dry = args.includes("--dry");
|
||||
|
||||
// Delete the files
|
||||
await rmDbs(dry);
|
||||
await rmDbs(dry);
|
||||
|
||||
Reference in New Issue
Block a user