[CmdSwitches] Rewrite cmd parsing to be simpler
This commit is contained in:
parent
513d004ce5
commit
f0f2d08f2c
1 changed files with 9 additions and 13 deletions
|
@ -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;
|
||||
let c = {};
|
||||
for (const x of ('base,' + (oaConfig.cmdPreset || 'perf')).split(',').reduce((a, x) => a.concat(presets[x]?.split(' ')), [])) {
|
||||
const [ k, v ] = x.split('=');
|
||||
|
||||
const [ key, value ] = cmd.split('=');
|
||||
|
||||
if (!acc[key]) acc[key] = [key];
|
||||
acc[key].push(value);
|
||||
(c[k] = c[k] || []).push(v);
|
||||
}
|
||||
|
||||
return acc;
|
||||
}, {}))) {
|
||||
app.commandLine.appendSwitch(key.replace('--', ''), values.join(','));
|
||||
for (const k in c) {
|
||||
app.commandLine.appendSwitch(k.replace('--', ''), c[k].join(','));
|
||||
}
|
||||
};
|
Loading…
Reference in a new issue