Skip to content

Commit

Permalink
Fix path handling for package install command
Browse files Browse the repository at this point in the history
  • Loading branch information
Thomas Anagrius authored and anagrius committed Oct 9, 2020
1 parent 3ff9074 commit 1d44ea7
Showing 1 changed file with 6 additions and 5 deletions.
11 changes: 6 additions & 5 deletions api/packages.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ import (
"io/ioutil"
"net/url"
"os"
"path"

"github.com/shurcooL/graphql"
)
Expand Down Expand Up @@ -197,7 +198,7 @@ func createZipFromFolder(baseFolder string, outFile *os.File) error {
return nil
}

func addFiles(w *zip.Writer, basePath, baseInZip string) {
func addFiles(w *zip.Writer, basePath string, baseInZip string) {
// Open the Directory
files, err := ioutil.ReadDir(basePath)
if err != nil {
Expand All @@ -206,13 +207,13 @@ func addFiles(w *zip.Writer, basePath, baseInZip string) {

for _, file := range files {
if !file.IsDir() {
dat, err := ioutil.ReadFile(basePath + file.Name())
dat, err := ioutil.ReadFile(path.Join(basePath, file.Name()))
if err != nil {
fmt.Println(err)
}

// Add some files to the archive.
f, err := w.Create(baseInZip + file.Name())
f, err := w.Create(path.Join(baseInZip, file.Name()))
if err != nil {
fmt.Println(err)
}
Expand All @@ -222,8 +223,8 @@ func addFiles(w *zip.Writer, basePath, baseInZip string) {
}
} else if file.IsDir() {
// Drill down
newBase := basePath + file.Name() + "/"
addFiles(w, newBase, baseInZip+file.Name()+"/")
newBase := path.Join(basePath, file.Name())
addFiles(w, newBase, path.Join(baseInZip, file.Name()))
}
}
}

0 comments on commit 1d44ea7

Please sign in to comment.