From 5ca740e799d9c24e3e8b394d46994f4421ac8ca7 Mon Sep 17 00:00:00 2001 From: Dennis <52335835+mastrolube@users.noreply.github.com> Date: Sat, 30 Sep 2023 18:03:24 +0200 Subject: [PATCH] handle multiline pm path packagename output --- utils.go | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/utils.go b/utils.go index fc66210..28b2d55 100644 --- a/utils.go +++ b/utils.go @@ -284,7 +284,12 @@ type PackageInfo struct { func readPackageInfo(packageName string) (info PackageInfo, err error) { outbyte, err := runShell("pm", "path", packageName) - output := strings.TrimSpace(string(outbyte)) + lines := strings.Split(string(outbyte), "\n") + if len(lines) == 0 { + err = errors.New("no output received") + return + } + output := strings.TrimSpace(lines[0]) if !strings.HasPrefix(output, "package:") { err = errors.New("package " + strconv.Quote(packageName) + " not found") return