Browse Source

Better support for adb result codes

pull/8/head
Daniel Martí 11 years ago
parent
commit
ea3545a1e5
  1. 15
      adb/adb.go

15
adb/adb.go

@ -153,7 +153,7 @@ func (d *Device) Install(path string) error {
if err := cmd.Start(); err != nil {
return err
}
line := getLine(stdout)
line := getResultLine(stdout)
if line == "Success" {
return nil
}
@ -243,12 +243,15 @@ func (d *Device) Install(path string) error {
return errors.New("unknown error: " + line)
}
func getLine(out io.ReadCloser) string {
func getResultLine(out io.ReadCloser) string {
scanner := bufio.NewScanner(out)
if !scanner.Scan() {
return ""
for scanner.Scan() {
l := scanner.Text()
if strings.HasPrefix(l, "Failure") || strings.HasPrefix(l, "Success") {
return l
}
}
return scanner.Text()
return ""
}
func (d *Device) Uninstall(pkg string) error {
@ -260,7 +263,7 @@ func (d *Device) Uninstall(pkg string) error {
if err := cmd.Start(); err != nil {
return err
}
line := getLine(stdout)
line := getResultLine(stdout)
if line == "Success" {
return nil
}

Loading…
Cancel
Save