Make admin init noninteractive
This commit is contained in:
+14
-5
@@ -9,11 +9,20 @@ if (!isDatabaseConfigured()) {
|
|||||||
process.exit(1);
|
process.exit(1);
|
||||||
}
|
}
|
||||||
|
|
||||||
const rl = readline.createInterface({ input, output });
|
const [usernameArg, passwordArg, confirmArg] = process.argv.slice(2);
|
||||||
const username = (await rl.question('admin username [admin]: ')).trim() || 'admin';
|
let username = (usernameArg ?? '').trim();
|
||||||
const password = await rl.question('admin password: ');
|
let password = passwordArg ?? '';
|
||||||
const confirm = await rl.question('confirm password: ');
|
let confirm = confirmArg ?? '';
|
||||||
rl.close();
|
|
||||||
|
if (!username || !password || !confirm) {
|
||||||
|
const rl = readline.createInterface({ input, output });
|
||||||
|
username = username || (await rl.question('admin username [admin]: ')).trim() || 'admin';
|
||||||
|
password = password || (await rl.question('admin password: '));
|
||||||
|
confirm = confirm || (await rl.question('confirm password: '));
|
||||||
|
rl.close();
|
||||||
|
} else {
|
||||||
|
username = username.trim() || 'admin';
|
||||||
|
}
|
||||||
|
|
||||||
if (!password || password !== confirm) {
|
if (!password || password !== confirm) {
|
||||||
console.error('密码为空或两次输入不一致');
|
console.error('密码为空或两次输入不一致');
|
||||||
|
|||||||
Reference in New Issue
Block a user