Skip to content

Commit ec4cd5e

Browse files
committed
Fix .task directory location
Closes #247
1 parent 59d2733 commit ec4cd5e

File tree

3 files changed

+12
-7
lines changed

3 files changed

+12
-7
lines changed

CHANGELOG.md

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,9 +2,12 @@
22

33
## Unreleased
44

5+
- Fix the `.task` directory being created in the task directory instead of the
6+
Taskfile directory
7+
([#247](https://github.com/go-task/task/issues/247)).
58
- Fix a bug where dynamic variables (those declared with `sh:`) were not
69
running in the task directory when the task has a custom dir or it was
7-
in an included taskfile
10+
in an included Taskfile
811
([#384](https://github.com/go-task/task/issues/384)).
912
- The watch feature (via the `--watch` flag) got a few different bug fixes and
1013
should be more stable now

internal/status/checksum.go

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,8 @@ import (
1414
// Checksum validades if a task is up to date by calculating its source
1515
// files checksum
1616
type Checksum struct {
17-
Dir string
17+
BaseDir string
18+
TaskDir string
1819
Task string
1920
Sources []string
2021
Generates []string
@@ -32,7 +33,7 @@ func (c *Checksum) IsUpToDate() (bool, error) {
3233
data, _ := ioutil.ReadFile(checksumFile)
3334
oldMd5 := strings.TrimSpace(string(data))
3435

35-
sources, err := globs(c.Dir, c.Sources)
36+
sources, err := globs(c.TaskDir, c.Sources)
3637
if err != nil {
3738
return false, err
3839
}
@@ -43,7 +44,7 @@ func (c *Checksum) IsUpToDate() (bool, error) {
4344
}
4445

4546
if !c.Dry {
46-
_ = os.MkdirAll(filepath.Join(c.Dir, ".task", "checksum"), 0755)
47+
_ = os.MkdirAll(filepath.Join(c.BaseDir, ".task", "checksum"), 0755)
4748
if err = ioutil.WriteFile(checksumFile, []byte(newMd5+"\n"), 0644); err != nil {
4849
return false, err
4950
}
@@ -52,7 +53,7 @@ func (c *Checksum) IsUpToDate() (bool, error) {
5253
if len(c.Generates) > 0 {
5354
// For each specified 'generates' field, check whether the files actually exist
5455
for _, g := range c.Generates {
55-
generates, err := glob(c.Dir, g)
56+
generates, err := glob(c.TaskDir, g)
5657
if os.IsNotExist(err) {
5758
return false, nil
5859
}
@@ -107,7 +108,7 @@ func (*Checksum) Kind() string {
107108
}
108109

109110
func (c *Checksum) checksumFilePath() string {
110-
return filepath.Join(c.Dir, ".task", "checksum", c.normalizeFilename(c.Task))
111+
return filepath.Join(c.BaseDir, ".task", "checksum", c.normalizeFilename(c.Task))
111112
}
112113

113114
var checksumFilenameRegexp = regexp.MustCompile("[^A-z0-9]")

status.go

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -76,7 +76,8 @@ func (e *Executor) timestampChecker(t *taskfile.Task) status.Checker {
7676

7777
func (e *Executor) checksumChecker(t *taskfile.Task) status.Checker {
7878
return &status.Checksum{
79-
Dir: t.Dir,
79+
BaseDir: e.Dir,
80+
TaskDir: t.Dir,
8081
Task: t.Name(),
8182
Sources: t.Sources,
8283
Generates: t.Generates,

0 commit comments

Comments
 (0)