gulpjs / gulp-cli

Command Line Interface for gulp.
MIT License
401 stars 106 forks source link

.gulp.json not working well with gulpfile.ts #181

Closed bjg2 closed 5 years ago

bjg2 commented 5 years ago

gulp version 4.0.0 gulp CLI version 2.0.1

Please take a look at gulp-typescript-fail repo, there is a small repro.

gulp test is not working and gulp test --gulpfile other_folder/gulpfile.ts is working, even though the same gulpfile is defined in .gulp.json. Also, if I execute gulp test --gulpfile other_folder/gulpfile.ts silent flag in .gulp.json is completely ignored, while it is working as expected if provided via CLI.

Even if I move gulpfile.ts is in the root and I change .gulp.json to point at gulpfile.ts, silent flag in the .gulp.json is working for default messages but is ignored for ts one and [22:39:59] Requiring external module ts-node/register is written. The same is not written if it is provided via CLI as gulp test --silent.

So the .gulp.json is not working for me, am I doing something wrong? How can we fix this?

sttk commented 5 years ago

There is a different behavior between --gulpfile option and flags.gulpfile in .gulp.js. --gulpfile options changes cwd but flags.gulpfile does not. These behaviors are still under consideration.

Maybe you can work that by the following way:

  1. Move .gulp.json in other_folder and modify gulpfile.ts path.
  2. Run the command gulp test --cwd other_folder. (flags.cwd is not supported yet, sorry.)
bjg2 commented 5 years ago

So it is not possible currently to have configs in .gulp.json (not in CLI), write gulpfile in typescript, and to have gulpfiles in other folders. :) Ok, I will align, but I am eagerly waiting for .gulp.js flags to be taken as default and CLI ones as override (I guess that is what everyone using .gulp.json expects to happen).

sttk commented 5 years ago

@bjg2 Sorry, I've mistaken. This problem is not about cwd but about autoloading a gulpfile in .gulp.js.

The cause is the lacking of preparing loader for a gulpfile in .gulp.js. The same process for a gulpfile by cli option is executed in liftoff by using rechoir.

I'll try to fix this issue this weekend.

sttk commented 5 years ago

but I am eagerly waiting for .gulp.js flags to be taken as default and CLI ones as override (I guess that is what everyone using .gulp.json expects to happen).

OK. I'll address that after this issue.

phated commented 5 years ago

A fix for this has been published in gulp-cli 2.1.0!

bjg2 commented 5 years ago

It works! Thanks!