mirror of
https://github.com/go-task/task.git
synced 2025-01-06 03:53:54 +02:00
fix: incorrect remote taskfiles cache directory
This commit is contained in:
parent
92f30d4d70
commit
ba299aa71f
24
setup.go
24
setup.go
@ -27,10 +27,10 @@ func (e *Executor) Setup() error {
|
|||||||
if err := e.setCurrentDir(); err != nil {
|
if err := e.setCurrentDir(); err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
if err := e.readTaskfile(); err != nil {
|
if err := e.setupTempDir(); err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
if err := e.setupTempDir(); err != nil {
|
if err := e.readTaskfile(); err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
e.setupFuzzyModel()
|
e.setupFuzzyModel()
|
||||||
@ -55,19 +55,32 @@ func (e *Executor) Setup() error {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func (e *Executor) setCurrentDir() error {
|
func (e *Executor) setCurrentDir() error {
|
||||||
|
// Default the directory to the current working directory
|
||||||
if e.Dir == "" {
|
if e.Dir == "" {
|
||||||
wd, err := os.Getwd()
|
wd, err := os.Getwd()
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
e.Dir = wd
|
e.Dir = wd
|
||||||
} else if !filepath.IsAbs(e.Dir) {
|
}
|
||||||
abs, err := filepath.Abs(e.Dir)
|
|
||||||
|
// Ensure we have an absolute path
|
||||||
|
abs, err := filepath.Abs(e.Dir)
|
||||||
|
if err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
e.Dir = abs
|
||||||
|
|
||||||
|
// If no entrypoint is specified, we need to search for a taskfile
|
||||||
|
if e.Entrypoint == "" {
|
||||||
|
root, err := read.ExistsWalk(e.Dir)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
e.Dir = abs
|
e.Dir = filepath.Dir(root)
|
||||||
|
e.Entrypoint = filepath.Base(root)
|
||||||
}
|
}
|
||||||
|
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -88,7 +101,6 @@ func (e *Executor) readTaskfile() error {
|
|||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
e.Dir = filepath.Dir(e.Taskfile.Location)
|
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -25,7 +25,7 @@ func NewFileNode(uri string, opts ...NodeOption) (*FileNode, error) {
|
|||||||
}
|
}
|
||||||
uri = d
|
uri = d
|
||||||
}
|
}
|
||||||
path, err := existsWalk(uri)
|
path, err := Exists(uri)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
|
@ -42,8 +42,8 @@ func readTaskfile(
|
|||||||
) (*taskfile.Taskfile, error) {
|
) (*taskfile.Taskfile, error) {
|
||||||
var b []byte
|
var b []byte
|
||||||
var err error
|
var err error
|
||||||
|
|
||||||
var cache *Cache
|
var cache *Cache
|
||||||
|
|
||||||
if node.Remote() {
|
if node.Remote() {
|
||||||
cache, err = NewCache(tempDir)
|
cache, err = NewCache(tempDir)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
@ -300,12 +300,12 @@ func Taskfile(
|
|||||||
return _taskfile(node)
|
return _taskfile(node)
|
||||||
}
|
}
|
||||||
|
|
||||||
// exists will check if a file at the given path exists. If it does, it will
|
// Exists will check if a file at the given path Exists. If it does, it will
|
||||||
// return the path to it. If it does not, it will search the search for any
|
// return the path to it. If it does not, it will search the search for any
|
||||||
// files at the given path with any of the default Taskfile files names. If any
|
// files at the given path with any of the default Taskfile files names. If any
|
||||||
// of these match a file, the first matching path will be returned. If no files
|
// of these match a file, the first matching path will be returned. If no files
|
||||||
// are found, an error will be returned.
|
// are found, an error will be returned.
|
||||||
func exists(path string) (string, error) {
|
func Exists(path string) (string, error) {
|
||||||
fi, err := os.Stat(path)
|
fi, err := os.Stat(path)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return "", err
|
return "", err
|
||||||
@ -324,19 +324,19 @@ func exists(path string) (string, error) {
|
|||||||
return "", errors.TaskfileNotFoundError{URI: path, Walk: false}
|
return "", errors.TaskfileNotFoundError{URI: path, Walk: false}
|
||||||
}
|
}
|
||||||
|
|
||||||
// existsWalk will check if a file at the given path exists by calling the
|
// ExistsWalk will check if a file at the given path exists by calling the
|
||||||
// exists function. If a file is not found, it will walk up the directory tree
|
// exists function. If a file is not found, it will walk up the directory tree
|
||||||
// calling the exists function until it finds a file or reaches the root
|
// calling the exists function until it finds a file or reaches the root
|
||||||
// directory. On supported operating systems, it will also check if the user ID
|
// directory. On supported operating systems, it will also check if the user ID
|
||||||
// of the directory changes and abort if it does.
|
// of the directory changes and abort if it does.
|
||||||
func existsWalk(path string) (string, error) {
|
func ExistsWalk(path string) (string, error) {
|
||||||
origPath := path
|
origPath := path
|
||||||
owner, err := sysinfo.Owner(path)
|
owner, err := sysinfo.Owner(path)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return "", err
|
return "", err
|
||||||
}
|
}
|
||||||
for {
|
for {
|
||||||
fpath, err := exists(path)
|
fpath, err := Exists(path)
|
||||||
if err == nil {
|
if err == nil {
|
||||||
return fpath, nil
|
return fpath, nil
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user