mirror of
https://github.com/reactivecircus/android-emulator-runner.git
synced 2026-09-03 19:09:32 +00:00
Allow increasing main storage size (sdcard is separate storage) (#219)
* Allow increasing disk size - Issue #184 * Fix checkDiskSize validator * Fix lint errors * Size modifier without a number is unacceptable "G" is not the same as "1G" * Implement checkDiskSize validator tests
This commit is contained in:
committed by
GitHub
parent
62d97062b0
commit
4e0dd2c343
@@ -69,3 +69,20 @@ export function checkEmulatorBuild(emulatorBuild: string): void {
|
||||
function isValidBoolean(value: string): boolean {
|
||||
return value === 'true' || value === 'false';
|
||||
}
|
||||
|
||||
export function checkDiskSize(diskSize: string): void {
|
||||
// Disk size can be empty - the default value
|
||||
if (diskSize) {
|
||||
// Can also be number of bytes
|
||||
if (isNaN(Number(diskSize)) || !Number.isInteger(Number(diskSize))) {
|
||||
// Disk size can have a size multiplier at the end K, M or G
|
||||
const diskSizeUpperCase = diskSize.toUpperCase();
|
||||
if (diskSizeUpperCase.endsWith('K') || diskSizeUpperCase.endsWith('M') || diskSizeUpperCase.endsWith('G')) {
|
||||
const diskSizeNoModifier: string = diskSize.slice(0, -1);
|
||||
if (0 == diskSizeNoModifier.length || isNaN(Number(diskSizeNoModifier)) || !Number.isInteger(Number(diskSizeNoModifier))) {
|
||||
throw new Error(`Unexpected disk size: '${diskSize}'.`);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user