gulp-cli
gulp-cli copied to clipboard
Expose `flags.cwd` as config option
The chdir
logic already comes later in the program so this one should be easy.
@phated I have a question about this flag.
Cli options --cwd
and --gulpfile
have relation to each other as follows:
$ gulp --cwd aaa/bbb
[23:10:19] Working directory changed to /path/to/aaa/bbb
[23:10:19] Using gulpfile /path/to/aaa/bbb/gulpfile.js
...
$ gulp --gulpfile aaa/bbb/gulpfile.js
[23:11:32] Working directory changed to /path/to/aaa/bbb
[23:11:32] Using gulpfile /path/to/aaa/bbb/gulpfile.js
...
$ gulp --cwd aaa/bbb --gulpfile ccc/ddd/gulpfile.js
[23:35:57] Working directory changed to /path/to/aaa/bbb
[23:35:57] Using gulpfile /path/to/ccc/ddd/gulpfile.js
...
And the current behavior with the config flag.gulpfile
is:
$ cat .gulp.json
{
"flags": {
"gulpfile": "aaa/bbb/gulpfile.js"
}
}
$ gulp
[23:13:33] Using gulpfile /path/to/aaa/bbb/gulpfile.js
...
Should these configs flag.gulpfile
and flag.cwd
have relations like cli options?
@sttk I think you may have missed some more examples because the current behavior seems to match? Maybe I'm just missing it.
@phated This behavior about cli options comes from liftoff
.
env.configPath
(=gulpfile path), env.configBase
(=gulpfile directory) and env.cwd
affect each other.
No other options used by liftoff
behave as such.
I noticed that a few options I wanted to expose as config options needed to be resolved before liftoff (e.g. nodeFlags
). I'm not sure how we should resolve these problems. Maybe @tkellen has an idea.
In the project we usegulp --gulpfile=aaa/bbb/gulpfile.js
and it works fine. Now we want to add default gulpfile path in the gulp config file .gulp.json
. However this does not work as expected. And I keep getting the error as below
Task 'default' is not in your gulpfile
When comparing to the logs in the output, we see using CLI option gulpfile
will change CWD first.
I am wondering if this could be fixed soon? Thanks!
@phated As @ericchenshine said above, current flags.gulpfile
in config file doesn't change cwd unlike --gulpfile
cli option. In addition, flags.gulpfile
in home dir resolves its relative path with home dir unlike flags.require
.
Should we give consistency to flags.gulpfile
with other cli options and config flags? (This would affect to behaviors when specifying combinations of all or some flags.gulpfile
, flags.cwd
, --gulpfile
and --cwd
.)
Parity would be great! This can now be solved with the Liftoff changes, correct?
-
For changing cwd by
flags.gulpfile
, we should change lib/shared/config/env-flags.js to replaceenv.cwd
toenv.configBase
when detectingenv.configPath
's change. -
For relative path of
flags.gulpfile
, this path resolving of gulpfile should be removed. This is same toflags.require
in #183.
@sttk I'm fine with those changes. The current behavior seems like a bug so we could probably release it in the same version as the other upcoming changes.
Due to how complex this issue has become, I'm going to move it to the 3.0 milestone because it might be breaking to some people's workflows.
This has moved to post-v5, but will actually fall into v6 because I plan to change the way Liftoff works and that should make this significantly easier/less error prone.