[CmdSwitches] Rewrite cmd parsing to be simpler

This commit is contained in:
Ducko 2022-04-22 17:44:20 +01:00
parent 513d004ce5
commit f0f2d08f2c
1 changed files with 9 additions and 13 deletions

View File

@ -8,18 +8,14 @@ const presets = {
module.exports = () => {
for (const [ key, ...values ] of Object.values([ 'base', ...(oaConfig.cmdPreset || 'perf').split(',') ].reduce((acc, x) => {
for (const cmd of (presets[x] || '').split(' ')) {
if (!cmd) continue;
const [ key, value ] = cmd.split('=');
if (!acc[key]) acc[key] = [key];
acc[key].push(value);
}
return acc;
}, {}))) {
app.commandLine.appendSwitch(key.replace('--', ''), values.join(','));
let c = {};
for (const x of ('base,' + (oaConfig.cmdPreset || 'perf')).split(',').reduce((a, x) => a.concat(presets[x]?.split(' ')), [])) {
const [ k, v ] = x.split('=');
(c[k] = c[k] || []).push(v);
}
for (const k in c) {
app.commandLine.appendSwitch(k.replace('--', ''), c[k].join(','));
}
};