Skip to content

Reset the `cwd` after each task run in case a plugin mistakenly changes it #493

Closed
shama opened this Issue Oct 23, 2012 · 5 comments

4 participants

@shama
grunt member
shama commented Oct 23, 2012

Ref #492

Also sometimes a plugin author might use a lib that changes the cwd without their knowledge. Bad practice but I'm sure it will happen.

@cowboy
grunt member
cowboy commented Oct 23, 2012

What happens if someone wants to write a task that changes the cwd? Is there actually a use-case for changing the cwd?

Maybe we should remove grunt.file.setBase and the user can use process.chdir themself if they need it.

Also, grunt could do a debug log of the cwd when running a task. It already logs the file the task lives in. We could probably log a lot more debugging information before/after running tasks.

@shama
grunt member
shama commented Oct 23, 2012

Tasks can change the cwd and even though a bad practice, it's okay, imo.

I don't think there is a valid use case for a task to change the cwd for other tasks though. Having other tasks rely on another task to change the cwd seems like a bad idea; one this issue is aimed to fix.

@kud
kud commented Oct 24, 2012

In any case, it should come back to default value on every end of each task. It's safer.

@cowboy
grunt member
cowboy commented Dec 31, 2012

This is a good idea, but I'm going to close this for now, and possibly implement it in 0.5.

@cowboy cowboy closed this Dec 31, 2012
@NickHeiner

+1 This would be useful to me. Would you be receptive to a PR implementing this?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Something went wrong with that request. Please try again.