Browse Source

Fix lint errors in wgpw

pull/1348/head
Hans Geel 2 years ago
parent
commit
5e9267ec48
  1. 23
      src/wgpw.mjs

23
src/wgpw.mjs

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

Loading…
Cancel
Save