diff --git a/src/wgpw.mjs b/src/wgpw.mjs index 34683b48..6ad6aede 100644 --- a/src/wgpw.mjs +++ b/src/wgpw.mjs @@ -2,8 +2,8 @@ // Import needed libraries import bcrypt from 'bcryptjs'; -import { Writable } from 'stream' -import readline from 'readline' +import { Writable } from 'stream'; +import readline from 'readline'; // Function to generate hash const generateHash = async (password) => { @@ -34,30 +34,27 @@ const comparePassword = async (password, hash) => { }; const readStdinPassword = () => { - return new Promise((resolve) => { - process.stdout.write("Enter your password: "); + process.stdout.write('Enter your password: '); const rl = readline.createInterface({ input: process.stdin, output: new Writable({ write(_chunk, _encoding, callback) { - callback() - } + callback(); + }, }), terminal: true, }); - rl.question('', answer => { + rl.question('', (answer) => { rl.close(); // Print a new line after password prompt process.stdout.write('\n'); resolve(answer); - }) - - }) - -} + }); + }); +}; (async () => { try { @@ -74,7 +71,7 @@ const readStdinPassword = () => { await generateHash(password); } else { const password = await readStdinPassword(); - await generateHash(password) + await generateHash(password); } } catch (error) { // eslint-disable-next-line no-console