()
| 129 | } |
| 130 | |
| 131 | func (e *Executor) setupTempDir() error { |
| 132 | if e.TempDir != (TempDir{}) { |
| 133 | return nil |
| 134 | } |
| 135 | |
| 136 | // e.TempDirPath carries the resolved CLI precedence (flag > TASK_TEMP_DIR > taskrc). |
| 137 | tempDir := cmp.Or(e.TempDirPath, ".task") |
| 138 | if filepath.IsAbs(tempDir) || strings.HasPrefix(tempDir, "~") { |
| 139 | tempDir, err := execext.ExpandLiteral(tempDir) |
| 140 | if err != nil { |
| 141 | return err |
| 142 | } |
| 143 | projectDir, _ := filepath.Abs(e.Dir) |
| 144 | projectName := filepath.Base(projectDir) |
| 145 | e.TempDir = TempDir{ |
| 146 | Remote: tempDir, |
| 147 | Fingerprint: filepathext.SmartJoin(tempDir, projectName), |
| 148 | } |
| 149 | |
| 150 | } else { |
| 151 | e.TempDir = TempDir{ |
| 152 | Remote: filepathext.SmartJoin(e.Dir, tempDir), |
| 153 | Fingerprint: filepathext.SmartJoin(e.Dir, tempDir), |
| 154 | } |
| 155 | } |
| 156 | |
| 157 | // RemoteCacheDir from taskrc/env can override the remote cache directory |
| 158 | if e.RemoteCacheDir != "" { |
| 159 | if filepath.IsAbs(e.RemoteCacheDir) || strings.HasPrefix(e.RemoteCacheDir, "~") { |
| 160 | remoteCacheDir, err := execext.ExpandLiteral(e.RemoteCacheDir) |
| 161 | if err != nil { |
| 162 | return err |
| 163 | } |
| 164 | e.TempDir.Remote = remoteCacheDir |
| 165 | } else { |
| 166 | e.TempDir.Remote = filepathext.SmartJoin(e.Dir, e.RemoteCacheDir) |
| 167 | } |
| 168 | } |
| 169 | |
| 170 | return nil |
| 171 | } |
| 172 | |
| 173 | func (e *Executor) setupStdFiles() { |
| 174 | if e.Stdin == nil { |
no test coverage detected