Skip to content

Commit 4269384

Browse files
Fix getting adb version when ANDROID_HOME is not set
In case ANDROID_HOME is not set, trying to get adb version leads to error. Fix this by checking the value of pathToAdbFromAndroidHome. In case it is not set, return null.
1 parent 72a4417 commit 4269384

File tree

1 file changed

+6
-1
lines changed

1 file changed

+6
-1
lines changed

lib/sys-info.ts

+6-1
Original file line numberDiff line numberDiff line change
@@ -160,7 +160,12 @@ export class SysInfo implements NativeScriptDoctor.ISysInfo {
160160

161161
public getAdbVersion(): Promise<string> {
162162
return this.getValueForProperty(() => this.adbVerCache, async (): Promise<string> => {
163-
const output = await this.childProcess.spawnFromEvent(await this.androidToolsInfo.getPathToAdbFromAndroidHome(), ["version"], "close", { ignoreError: true });
163+
let output: IProcessInfo = null;
164+
const pathToAdbFromAndroidHome = await this.androidToolsInfo.getPathToAdbFromAndroidHome();
165+
if (pathToAdbFromAndroidHome) {
166+
output = await this.childProcess.spawnFromEvent(pathToAdbFromAndroidHome, ["version"], "close", { ignoreError: true });
167+
}
168+
164169
return output && output.stdout ? this.getVersionFromString(output.stdout) : null;
165170
});
166171
}

0 commit comments

Comments
 (0)