Skip to content

Commit

Permalink
fix failing
Browse files Browse the repository at this point in the history
  • Loading branch information
Ianyourgod committed Feb 26, 2024
1 parent c88c58f commit f52e874
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 5 deletions.
14 changes: 13 additions & 1 deletion api/db/UMTests.js
Original file line number Diff line number Diff line change
@@ -1,11 +1,13 @@
const UserManager = require('./UserManager');
const prompt = require('prompt-sync')();
const colors = require('colors');


const understands = process.argv.includes("-u") ||
let understands = process.argv.includes("-u") ||
process.argv.includes("--understands");

async function tests() {

const manager = new UserManager();
await manager.init();

Expand Down Expand Up @@ -393,6 +395,16 @@ async function tests() {


(async () => {
if (!understands) {
let pmt = prompt("This will reset the database, are you sure? (Y/n) ");
if (typeof pmt !== "string" ||
pmt === "n"
) {
process.exit(0);
}
understands = true;
}

let result = await tests();
if (result) {
console.log("[ PASS ]".green, "All tests passed");
Expand Down
15 changes: 11 additions & 4 deletions api/db/UserManager.js
Original file line number Diff line number Diff line change
Expand Up @@ -55,14 +55,21 @@ class UserManager {
*/
async reset(understands = false) {
if (!understands) {
if (prompt("This deletes ALL DATA. Are you sure? (Y/n) ") === "n")
return;
let unde = prompt("This deletes ALL DATA. Are you sure? (Y/n) ")
if (
typeof unde !== "string"
) {
return;
}
console.log(typeof unde)
}
await this.users.deleteMany({});
await this.reports.deleteMany({});
await this.projects.deleteMany({});
fs.rmSync(path.join(__dirname, "projects/files"), { recursive: true, force: true });
fs.rmSync(path.join(__dirname, "projects/images"), { recursive: true, force: true });
if (fs.existsSync(path.join(__dirname, "projects/files")) && fs.existsSync(path.join(__dirname, "projects/images"))) {
fs.rmSync(path.join(__dirname, "projects/files"), { recursive: true, force: true });
fs.rmSync(path.join(__dirname, "projects/images"), { recursive: true, force: true });
}
fs.mkdirSync(path.join(__dirname, "projects/files"));
fs.mkdirSync(path.join(__dirname, "projects/images"));
}
Expand Down

0 comments on commit f52e874

Please sign in to comment.