[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

View file

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