frankwallis / gulp-hub

Gulp plugin to run tasks in multiple gulpfiles
MIT License
89 stars 24 forks source link

TypeError: gulp.registry.get is not a function #40

Closed davidmpaz closed 7 years ago

davidmpaz commented 7 years ago

Hi,

I can see that HubRegistry inherits from ForwardRegistry which should have the functions defined from gulpjs/undertaker. So methods defined should be there.

Still, after creating hub with other gulp files and setting registry gulp.registry(hub); I am doing: gulp.registry.get('sass') and I get the error. sass is one of the tasks defined in the child gulp files.

Any idea why is this happening? Am i missing something?

Thanks in advance

frankwallis commented 7 years ago

Which version of gulp-hub are you using? If you are using gulp4 then you need to do npm install gulp-hub@next as per https://github.com/frankwallis/gulp-hub/issues/39

Probably I should add this to the readme...

davidmpaz commented 7 years ago

Hi @frankwallis ,

thanks for answering and sorry for reporting status so early, is not fixed yet for me.

Regarding adding docs to readme, will be usefull for newcomers like me :)

Regarding issue. Yes, I am using gulp4. The hub version from package.json was:

"gulp-hub": "github:frankwallis/gulp-hub#registry-init"

now, after your suggestion is: gulp-hub@4.1.0

I gave a deeper look to it. I noticed that utils is used in HubRegsitry but not referenced in packages.json as dependency. Still, installing util did not fix the issue.

The output for console.dir(hub, { depth: null }); in my gulp file is:

HubRegistry {
  _tasks: {},
  _registry: { 'theme/gulpfile.js': ForwardRefRegistry { _tasks: {} } },
  _callsite: 'theme/gulpfile.js',
  _gulpfiles: 
   [ 'theme/gulp/images.js',
     'theme/gulp/scripts.js',
     'theme/gulp/sass.js',
     'theme/gulp/fonts.js',
     'theme/gulp/php.js' ] }

and output for console.log(Object.getOwnPropertyNames(HubRegistry.prototype)); was:

[ 'constructor', 'getCallSite', 'init', 'set' ]

the way I am using it in my gulp file is:

const gulp = require('gulp');
const HubRegistry = require('gulp-hub');

let hub = new HubRegistry([
  config.images.default.taskFile, config.typescript.default.taskFile,
  config.scss.default.taskFile, config.fonts.default.taskFile,
  config.php.default.taskFile
]);

gulp.registry(hub);

const watch = () => gulp.series(
  gulp.registry.get('sass:watch'), gulp.registry.get('scripts:watch')
);

const dev = gulp.series(watch);
gulp.task('default', dev);

sass:watch and scripts:watch are tasks defined in previously added gulpfiles.

Thanks again. Please, ask in case you think more info should be added.