Add version() function

This commit is contained in:
Elara 2022-10-02 20:09:12 -07:00
parent e2c8335381
commit a42c9b27e7
1 changed files with 21 additions and 0 deletions

View File

@ -19,6 +19,7 @@
package main
import (
"bytes"
"context"
"encoding/hex"
"io"
@ -233,6 +234,26 @@ func buildPackage(ctx context.Context, script string, mgr manager.Manager) ([]st
}
}
fn, ok = dec.GetFunc("version")
if ok {
log.Info("Executing version()").Send()
buf := &bytes.Buffer{}
err = fn(
ctx,
interp.Dir(srcdir),
interp.StdIO(os.Stdin, buf, os.Stderr),
)
if err != nil {
return nil, nil, err
}
vars.Version = strings.TrimSpace(buf.String())
log.Info("Updating version").Str("new", vars.Version).Send()
}
fn, ok = dec.GetFunc("build")
if ok {
log.Info("Executing build()").Send()