Skip to content

Commit f7ed558

Browse files
Merge pull request #14 from NativeScript/vladimirov/fix-interval-android
Fix getting information about adb
2 parents 1ee7a42 + e575dab commit f7ed558

File tree

3 files changed

+12
-7
lines changed

3 files changed

+12
-7
lines changed

lib/sys-info.ts

+2-2
Original file line numberDiff line numberDiff line change
@@ -160,8 +160,8 @@ 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.execCommand(`${await this.androidToolsInfo.getPathToAdbFromAndroidHome()} version`);
164-
return output ? this.getVersionFromString(output) : null;
163+
const output = await this.childProcess.spawnFromEvent(await this.androidToolsInfo.getPathToAdbFromAndroidHome(), ["version"], "close", { ignoreError: true });
164+
return output && output.stdout ? this.getVersionFromString(output.stdout) : null;
165165
});
166166
}
167167

package.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "nativescript-doctor",
3-
"version": "0.3.1",
3+
"version": "0.3.2",
44
"description": "Library that helps identifying if the environment can be used for development of {N} apps.",
55
"main": "lib/index.js",
66
"types": "./typings/nativescript-doctor.d.ts",

test/sys-info.ts

+9-4
Original file line numberDiff line numberDiff line change
@@ -71,6 +71,7 @@ function createChildProcessResults(childProcessResult: IChildProcessResults): ID
7171
"xcodebuild -version": childProcessResult.xCodeVersion,
7272
"pod --version": childProcessResult.podVersion,
7373
"pod": childProcessResult.pod,
74+
'adb': childProcessResult.adbVersion,
7475
'adb version': childProcessResult.adbVersion,
7576
"'adb' version": childProcessResult.adbVersion, // for Mac and Linux
7677
'android': childProcessResult.androidInstalled,
@@ -83,9 +84,13 @@ function createChildProcessResults(childProcessResult: IChildProcessResults): ID
8384
};
8485
}
8586

86-
function getResultFromChildProcess(childProcessResultDescription: IChildProcessResultDescription, command: string): any {
87+
function getResultFromChildProcess(childProcessResultDescription: IChildProcessResultDescription, command: string, options?: ISpawnFromEventOptions): any {
8788
if (childProcessResultDescription.shouldThrowError) {
88-
throw new Error(`This one throws error. (${command})`);
89+
if (options && options.ignoreError) {
90+
return null;
91+
} else {
92+
throw new Error(`This one throws error. (${command})`);
93+
}
8994
}
9095

9196
return childProcessResultDescription.result;
@@ -111,8 +116,8 @@ function mockSysInfo(childProcessResult: IChildProcessResults, hostInfoOptions?:
111116
exec: async (command: string) => {
112117
return getResultFromChildProcess(childProcessResultDictionary[command], command);
113118
},
114-
spawnFromEvent: async (command: string, args: string[], event: string) => {
115-
return getResultFromChildProcess(childProcessResultDictionary[command], command);
119+
spawnFromEvent: async (command: string, args: string[], event: string, options: ISpawnFromEventOptions) => {
120+
return getResultFromChildProcess(childProcessResultDictionary[command], command, options);
116121
},
117122
execFile: async () => {
118123
return undefined;

0 commit comments

Comments
 (0)