Skip to content

Commit

Permalink
feat: embed app in zip
Browse files Browse the repository at this point in the history
  • Loading branch information
CommonGuy committed Oct 31, 2023
1 parent b234e4f commit 8227f8a
Showing 1 changed file with 16 additions and 1 deletion.
17 changes: 16 additions & 1 deletion package/zip/zip.go
Original file line number Diff line number Diff line change
Expand Up @@ -132,12 +132,27 @@ func createRoot(ctx context.Context, logger hclog.Logger, opts *Options) (string
return "", err
}

// further nest the files into another folder with the
// same name as the app.
// This ensures zip files contain the app, rather than the contents
// of the app folder.
// see https://github.com/mitchellh/gon/issues/18
appDir := root
if len(opts.Files) == 1 {
appName := filepath.Base(opts.Files[0])
appDir = filepath.Join(root, appName)
err = os.MkdirAll(appDir, 0777)
if err != nil {
return "", err
}
}

// Setup our args to copy our files into the root
cmd.Args = []string{
filepath.Base(cmd.Path),
}
cmd.Args = append(cmd.Args, opts.Files...)
cmd.Args = append(cmd.Args, root)
cmd.Args = append(cmd.Args, appDir)

// We store all output in out for logging and in case there is an error
var out bytes.Buffer
Expand Down

0 comments on commit 8227f8a

Please sign in to comment.