This is an automated email from the ASF dual-hosted git repository.

kezhenxu94 pushed a commit to branch main
in repository https://gitbox.apache.org/repos/asf/skywalking-eyes.git


The following commit(s) were added to refs/heads/main by this push:
     new 8157269  Fix the licenses files location problem (#70)
8157269 is described below

commit 8157269dc4fc4bd9f47c5190e94146781f4a5f42
Author: Youhan Wu <[email protected]>
AuthorDate: Tue Sep 14 21:19:41 2021 -0500

    Fix the licenses files location problem (#70)
---
 commands/deps_resolve.go | 8 +++++++-
 1 file changed, 7 insertions(+), 1 deletion(-)

diff --git a/commands/deps_resolve.go b/commands/deps_resolve.go
index 0a43a0a..0698af3 100644
--- a/commands/deps_resolve.go
+++ b/commands/deps_resolve.go
@@ -20,6 +20,7 @@ package commands
 import (
        "fmt"
        "os"
+       "path/filepath"
        "regexp"
        "strings"
 
@@ -46,6 +47,11 @@ var DepsResolveCommand = &cobra.Command{
                if outDir == "" {
                        return nil
                }
+               absPath, err := filepath.Abs(outDir)
+               if err != nil {
+                       return err
+               }
+               outDir = absPath
                if err := os.MkdirAll(outDir, 0700); err != nil && 
!os.IsExist(err) {
                        return err
                }
@@ -83,7 +89,7 @@ var DepsResolveCommand = &cobra.Command{
 
 func writeLicense(result *deps.Result) {
        filename := 
string(fileNamePattern.ReplaceAll([]byte(result.Dependency), []byte("-")))
-       filename = strings.TrimRight(outDir, "/") + "/license-" + filename + 
".txt"
+       filename = filepath.Join(outDir, "license-"+filename+".txt")
        file, err := os.Create(filename)
        if err != nil {
                logger.Log.Errorf("failed to create license file %v: %v", 
filename, err)

Reply via email to