mirror of
https://github.com/EnumeratedDev/bpm.git
synced 2026-09-16 02:26:12 +00:00
Replace variables in download filepath during compilation
This commit is contained in:
@@ -438,6 +438,10 @@ func downloadPackageFiles(pkgInfo *PackageInfo, tempDirectory string, verbose bo
|
|||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
filepath, err := envsubst.Eval(strings.TrimSpace(download.Filepath), replaceVars)
|
||||||
|
if err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
extractTo, err := envsubst.Eval(strings.TrimSpace(download.ExtractTo), replaceVars)
|
extractTo, err := envsubst.Eval(strings.TrimSpace(download.ExtractTo), replaceVars)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
@@ -458,9 +462,11 @@ func downloadPackageFiles(pkgInfo *PackageInfo, tempDirectory string, verbose bo
|
|||||||
|
|
||||||
switch download.Type {
|
switch download.Type {
|
||||||
case "", "file":
|
case "", "file":
|
||||||
filepath := path.Join(tempDirectory, path.Base(downloadUrl))
|
if filepath == "" {
|
||||||
if download.Filepath != "" && download.Filepath[0] != '/' {
|
filepath = path.Join(tempDirectory, path.Base(downloadUrl))
|
||||||
filepath = path.Join(tempDirectory, download.Filepath)
|
}
|
||||||
|
if filepath[0] != '/' {
|
||||||
|
filepath = path.Join(tempDirectory, filepath)
|
||||||
}
|
}
|
||||||
|
|
||||||
err := downloadFile("Downloading file "+path.Base(filepath), downloadUrl, filepath, 0644)
|
err := downloadFile("Downloading file "+path.Base(filepath), downloadUrl, filepath, 0644)
|
||||||
|
|||||||
@@ -51,7 +51,7 @@ type PackageInfo struct {
|
|||||||
type PackageDownload struct {
|
type PackageDownload struct {
|
||||||
Url string `yaml:"url"`
|
Url string `yaml:"url"`
|
||||||
Type string `yaml:"type,omitempty"`
|
Type string `yaml:"type,omitempty"`
|
||||||
Filepath string `yaml:"filepath,omitempty,omitempty"`
|
Filepath string `yaml:"filepath,omitempty"`
|
||||||
|
|
||||||
// Archive options
|
// Archive options
|
||||||
NoExtract bool `yaml:"no_extract,omitempty"`
|
NoExtract bool `yaml:"no_extract,omitempty"`
|
||||||
|
|||||||
Reference in New Issue
Block a user