Fix broken --android parsing. (#4422)

* Fix broken --android parsing.

After this --android will work but will not be showed as an alias.
The problem was that we had issues with the android configuration
object becoming an array instead of an object.
This commit is contained in:
Peter Hedenskog 2025-02-02 14:04:16 +01:00 committed by GitHub
parent f19fb295de
commit be83456da4
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
1 changed files with 9 additions and 8 deletions

View File

@ -25,6 +25,10 @@ const version = require('../../package.json').version;
const configFiles = ['.sitespeed.io.json'];
function fixAndroidArgs(args) {
return args.map(arg => (arg === '--android' ? '--android.enabled' : arg));
}
if (process.argv.includes('--config')) {
const index = process.argv.indexOf('--config');
configFiles.unshift(process.argv[index + 1]);
@ -214,11 +218,8 @@ function validateInput(argv) {
}
export async function parseCommandLine() {
let argvFix = process.argv.map(arg =>
arg === '--android' ? '--android.enabled' : arg
);
let yargsInstance = yargs(hideBin(argvFix));
const fixedArgs = fixAndroidArgs(hideBin(process.argv));
const yargsInstance = yargs(fixedArgs);
let parsed = yargsInstance
.parserConfiguration({
'camel-case-expansion': false,
@ -860,8 +861,8 @@ export async function parseCommandLine() {
'Process name of the Activity hosting the WebView. If not given, the process name is assumed to be the same as chrome.android.package.',
group: 'Chrome'
})
.option('browsertime.android', {
alias: 'android',
.option('browsertime.android.enabled', {
alias: ['android.enabled'],
type: 'boolean',
default: false,
describe:
@ -2194,7 +2195,7 @@ export async function parseCommandLine() {
if (argv.ios) {
set(argv, 'safari.ios', true);
} else if (argv.android && argv.browser === 'chrome') {
} else if (argv.android.enabled === true && argv.browser === 'chrome') {
// Default to Chrome Android.
set(
argv,