Skip to content

pipe.MkDirAll runs instantly not sequentially in pipe.Script #4

@stephen-soltesz

Description

@stephen-soltesz

In a pipe.Script context, my expectation is that every step runs sequentially, where earlier steps complete before later steps start.

I discovered that a few functions like pipe.MkDirAll run instantly, irrespective of their position in the pipe.Script.

For example:

pipe.Script(
	pipe.System("sleep 2 && test ! -d newdir"),     // wait then fail.
	pipe.MkDirAll("newdir/subdir", 0755),           // runs before first step completes
),

If my understanding is correct, it looks like this behavior could be changed by using a TaskFunc in the implementation of MkDirAll.

For example:

func syncMkDirAll(dir string, perm os.FileMode) pipe.Pipe {
	return pipe.TaskFunc(func(s *pipe.State) error {
		return os.MkdirAll(s.Path(dir), perm)
	})
}

What do you think of making MkDir* a TaskFunc by default?

Thanks!

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions