Skip to content

Commit 0e606a3

Browse files
author
Vladimir Enchev
committed
code improved
1 parent 9b7d243 commit 0e606a3

File tree

1 file changed

+10
-15
lines changed

1 file changed

+10
-15
lines changed

lib/services/platform-service.ts

+10-15
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
///<reference path="../.d.ts"/>
22
"use strict";
33

4+
import * as child_process from "child_process";
45
import * as path from "path";
56
import * as shell from "shelljs";
67
import * as constants from "../constants";
@@ -486,24 +487,18 @@ export class PlatformService implements IPlatformService {
486487

487488
if (this.$options.availableDevices) {
488489
return (() => {
489-
let exec = require("child_process").exec;
490+
let callback = (error: Error, stdout: Buffer, stderr: Buffer) => {
491+
if (error !== null) {
492+
this.$errors.fail(error);
493+
} else {
494+
this.$logger.info(stdout);
495+
}
496+
};
490497

491498
if (this.$mobileHelper.isiOSPlatform(platform)) {
492-
exec("instruments -s devices", (error: Error, stdout: string, stderr: string) => {
493-
if (error !== null) {
494-
this.$errors.fail(error);
495-
} else {
496-
this.$logger.info(stdout);
497-
}
498-
});
499+
child_process.exec("instruments -s devices", callback);
499500
} else if (this.$mobileHelper.isAndroidPlatform(platform)) {
500-
exec("android list avd", (error: Error, stdout: string, stderr: string) => {
501-
if (error !== null) {
502-
this.$errors.fail(error);
503-
} else {
504-
this.$logger.info(stdout);
505-
}
506-
});
501+
child_process.exec("android list avd", callback);
507502
}
508503
}).future<void>()();
509504
} else {

0 commit comments

Comments
 (0)