Updating splitting of avd names to work on Windows and Unix based sys… (#3041)

Summary:
…tems

When trying to start an android emulator in Windows, there is a failure in trying to read `<avd name>.ini`. The reason for this is because when we run `<android sdk path>\tools\emulator.exe -list-avds`, a split is performed with the new line character (`\n`). Unfortunately, this does not work for Windows, which uses `\r\n` as the new line termination. This results in a carriage return remaining on each output string, which results in trying to access `<avd name> .ini`, which is an invalid path.

The fix is to update the split to use a regex that is compatible for both Unix and Windows based systems.

## Changelog

Updating splitting of avd names to work on Windows and Unix based systems

Pull Request resolved: https://github.com/facebook/flipper/pull/3041

Test Plan: Verified the avd names didn't have any trailing whitespace, and the emulator is able to launch.

Reviewed By: mweststrate

Differential Revision: D32387162

Pulled By: nikoant

fbshipit-source-id: 0900bee17b225cfa5484a29c96f8e2c1c2e31477
This commit is contained in:
Ranesh Saha
2021-11-12 08:06:03 -08:00
committed by Facebook GitHub Bot
parent eb28fc411b
commit ddb4e70c2a

View File

@@ -149,7 +149,7 @@ export class AndroidDeviceManager {
return;
}
const devices = data
.split('\n')
.split(/\r?\n/)
.filter(notNull)
.filter((l) => l !== '');
resolve(devices);