Remove boolean equality checks from cliArguments

yargs ensures that the Boolean options will always be booleans, so the
strict equality checks are unnecessary.
This commit is contained in:
valadaptive
2023-12-06 13:29:58 -05:00
parent 64496425cc
commit e65d1ad20f

View File

@ -74,7 +74,7 @@ dns.setDefaultResultOrder('ipv4first');
const cliArguments = yargs(hideBin(process.argv)) const cliArguments = yargs(hideBin(process.argv))
.option('autorun', { .option('autorun', {
type: 'boolean', type: 'boolean',
default: null, default: true,
describe: 'Automatically launch SillyTavern in the browser.', describe: 'Automatically launch SillyTavern in the browser.',
}).option('corsProxy', { }).option('corsProxy', {
type: 'boolean', type: 'boolean',
@ -124,7 +124,7 @@ if (fs.existsSync(whitelistPath)) {
} }
const whitelistMode = getConfigValue('whitelistMode', true); const whitelistMode = getConfigValue('whitelistMode', true);
const autorun = getConfigValue('autorun', false) && cliArguments.autorun !== false && !cliArguments.ssl; const autorun = getConfigValue('autorun', false) && cliArguments.autorun && !cliArguments.ssl;
const enableExtensions = getConfigValue('enableExtensions', true); const enableExtensions = getConfigValue('enableExtensions', true);
const listen = getConfigValue('listen', false); const listen = getConfigValue('listen', false);
@ -220,7 +220,7 @@ const { DIRECTORIES, UPLOADS_PATH, PALM_SAFETY, TEXTGEN_TYPES, CHAT_COMPLETION_S
const { TavernCardValidator } = require('./src/validator/TavernCardValidator'); const { TavernCardValidator } = require('./src/validator/TavernCardValidator');
// CSRF Protection // // CSRF Protection //
if (cliArguments.disableCsrf === false) { if (!cliArguments.disableCsrf) {
const CSRF_SECRET = crypto.randomBytes(8).toString('hex'); const CSRF_SECRET = crypto.randomBytes(8).toString('hex');
const COOKIES_SECRET = crypto.randomBytes(8).toString('hex'); const COOKIES_SECRET = crypto.randomBytes(8).toString('hex');
@ -306,7 +306,7 @@ app.use(function (req, res, next) {
next(); next();
}); });
if (getConfigValue('enableCorsProxy', false) === true || cliArguments.corsProxy === true) { if (getConfigValue('enableCorsProxy', false) === true || cliArguments.corsProxy) {
const bodyParser = require('body-parser'); const bodyParser = require('body-parser');
app.use(bodyParser.json()); app.use(bodyParser.json());
console.log('Enabling CORS proxy'); console.log('Enabling CORS proxy');
@ -3687,7 +3687,7 @@ if (listen && !getConfigValue('whitelistMode', true) && !getConfigValue('basicAu
} }
} }
if (true === cliArguments.ssl) { if (cliArguments.ssl) {
https.createServer( https.createServer(
{ {
cert: fs.readFileSync(cliArguments.certPath), cert: fs.readFileSync(cliArguments.certPath),