gulpjs / liftoff

Launch your command line tool with ease.
MIT License
843 stars 52 forks source link

Add option to set cwd in `Liftoff` constructor #78

Closed weswigham closed 8 years ago

weswigham commented 8 years ago

This way the appropriate cwd can be set when all register hooks get hooked in. This is an issue in, for example, gulp when using ts-node in a subdirectory with --cwd. The cwd passed is not respected by the require hooks included by liftoff since the cwd is only set during launch (so it is not set when the require hook is loaded).

phated commented 8 years ago

The require hooks are loaded with node's require which doesn't take into account a cwd parameter and instead use process.cwd(). Liftoff should not be responsible for changing that (although, gulp decides to do that in its CLI). @tkellen do you agree?

weswigham commented 8 years ago

So the correct fix would instead be, in gulp, before it's construction of Liftoff, using process.chdir?

phated commented 8 years ago

@weswigham that would be the only place where we'd consider it. If you open an issue on gulp-cli, we can discuss over there. It would effect this chunk of code: https://github.com/gulpjs/gulp-cli/blob/master/index.js#L131-L137

Closing this.

tkellen commented 8 years ago

Agreed @phated! If we wind up thinking this is a best practice, we should consider updating hacker to do it as well.