Skip to content

Commit

Permalink
Fix build
Browse files Browse the repository at this point in the history
  • Loading branch information
renatodellosso committed Feb 1, 2025
1 parent fc2bf67 commit fecac39
Show file tree
Hide file tree
Showing 3 changed files with 27 additions and 22 deletions.
24 changes: 24 additions & 0 deletions lib/ScriptUtils.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
/**
* DO NOT IMPORT THIS FILE IN FILES USED IN THE WEBSITE ITSELF
*/
import { createInterface } from "readline";

/**
* Intended for use in scripts
*
* @param prompt What to ask the user
* @returns The user's input
*/
export function getCommandLineInput(prompt: string) {
return new Promise<string>((resolve) => {
const readline = createInterface({
input: process.stdin,
output: process.stdout,
});

readline.question(prompt + " ", (answer: string) => {
readline.close();
resolve(answer);
});
});
}
22 changes: 1 addition & 21 deletions lib/Utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -141,24 +141,4 @@ export async function repairUser(
);

return user as User;
}

/**
* Intended for use in scripts
*
* @param prompt What to ask the user
* @returns The user's input
*/
export function getCommandLineInput(prompt: string) {
return new Promise<string>((resolve) => {
const readline = require("readline").createInterface({
input: process.stdin,
output: process.stdout,
});

readline.question(prompt + " ", (answer: string) => {
readline.close();
resolve(answer);
});
});
}
}
3 changes: 2 additions & 1 deletion scripts/repairUsers.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import CollectionId from "@/lib/client/CollectionId";
import { getDatabase } from "@/lib/MongoDB";
import { getCommandLineInput, repairUser } from "@/lib/Utils";
import { getCommandLineInput } from "@/lib/ScriptUtils";
import { repairUser } from "@/lib/Utils";

async function repairUsers() {
console.log("Getting database...");
Expand Down

0 comments on commit fecac39

Please sign in to comment.