Skip to content

Commit

Permalink
wip
Browse files Browse the repository at this point in the history
Signed-off-by: Leonardo Grasso <me@leonardograsso.com>
  • Loading branch information
leogr committed Sep 6, 2023
1 parent 4af105a commit b2034e1
Showing 1 changed file with 32 additions and 2 deletions.
34 changes: 32 additions & 2 deletions pkg/run/executable.go
Original file line number Diff line number Diff line change
Expand Up @@ -73,14 +73,41 @@ func (e *execRunner) Run(ctx context.Context, options ...RunnerOption) error {
for _, f := range opts.files {
// if file's name is a relative path, copy it in the workdir
if !path.IsAbs(f.Name()) {
newAbsPath := e.WorkDir() + "/" + f.Name()
newAbsPath, err := filepath.Abs(filepath.Join(e.WorkDir(), f.Name()))
if err != nil {
return err
}
if err := os.MkdirAll(filepath.Dir(newAbsPath), os.ModePerm); err != nil {
return err
}
if local, ok := f.(*localFileAccessor); ok {
if err := os.Symlink(local.path, newAbsPath); err != nil {
localAbsPath, err := filepath.Abs(local.path)
if err != nil {
return err
}
if fileinfo, err := os.Stat(localAbsPath); err != nil {
return err
} else {
fmt.Println("SRC fileinfo:", fileinfo.Name(), fileinfo.Size(), fileinfo.Mode())
}
// copy
fmt.Println("copying", localAbsPath, "to", newAbsPath)
content, err := os.ReadFile(localAbsPath)
if err != nil {
return err
}
err = os.WriteFile(newAbsPath, content, os.ModePerm)
if err != nil {
return err
}
if fileinfo, err := os.Stat(newAbsPath); err != nil {
return err
} else {
fmt.Println("DST fileinfo:", fileinfo.Name(), fileinfo.Size(), fileinfo.Mode())
}
// if err := os.Symlink(localAbsPath, newAbsPath); err != nil {
// return err
// }
} else {
content, err := f.Content()
if err != nil {
Expand Down Expand Up @@ -111,6 +138,9 @@ func (e *execRunner) Run(ctx context.Context, options ...RunnerOption) error {
cmd.Env = append(cmd.Env, fmt.Sprintf(`%s=%s`, k, v))
}

fmt.Println("Working dir:", e.WorkDir())
fmt.Println(cmd)

err := cmd.Run()
if exitErr, ok := err.(*exec.ExitError); ok && exitErr.ExitCode() != 0 {
err = &ExitCodeError{Code: exitErr.ExitCode()}
Expand Down

0 comments on commit b2034e1

Please sign in to comment.