Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

meta is undefined #31

Closed
mikehaas763 opened this issue Jul 17, 2015 · 8 comments
Closed

meta is undefined #31

mikehaas763 opened this issue Jul 17, 2015 · 8 comments
Milestone

Comments

@mikehaas763
Copy link

I'm using latest in gulpjs/gulp#4.0. When I try to use any of the commands like gulp --tasks or when WebStorm tries to run gulp --tasks-json I get an error.

 return meta.tree;
            ^

TypeError: Cannot read property 'tree' of undefined

I can post the full stack trace if needed. This may just be a known issue because it's in the middle of development but I thought I'd at least get it logged in case not.

@phated
Copy link
Member

phated commented Jul 17, 2015

I'm not getting this error, can you provide some more information?

@mikehaas763
Copy link
Author

I couldn't reproduce this on my personal computer tonight so I'll try it on my work computer again tomorrow which is the original computer I had the problem on.

@mikehaas763
Copy link
Author

I spent some time trying to track down the issue again. It seems to only be happening when I use a custom registry. I have a very basic custom registry which inherits from undertaker-registry.

'use strict';

var util = require('util');
var DefaultRegistry = require('undertaker-registry');

module.exports = BuildTasksRegistry;

util.inherits(BuildTasksRegistry, DefaultRegistry);
function BuildTasksRegistry() {
    DefaultRegistry.call(this);

    this.set('clean', function(done) {
        console.log('cleaning');
        done();
    });
}

My gulpfile is also very simple

'use strict';

var gulp = require('gulp');
var BuildTasksRegistry = require('./gulp/BuildTasksRegistry.js');

var buildTasks = new BuildTasksRegistry();
gulp.registry(buildTasks);

I can successfully run the command gulp clean. However, like I mentioned originally gulp --tasks results in that error being thrown.

I'm using undertaker-registry version 0.0.3
with gulpjs/gulp#4.0 branch

When I step into gulp and therefore into undertaker I notice the assignment to meta in tree.js.

var meta = metadata.get(task);

Looking at the contents of the metadata module that's being used in the line above, I can see it's simply a new instance of a WeakMap being exported. However, that WeakMap instance has never had any keys set. Therefore meta is undefined from the metadata.get(task) evaluation.

Does it look like I'm doing anything wrong or do you know what the metadata section is supposed to actually do?

@aleogr
Copy link

aleogr commented Aug 4, 2015

Same error here

@phated
Copy link
Member

phated commented Aug 10, 2015

@mikehaas763 can you please check out #25 - we have a new way of defining custom tasks (in an init method on the registry). The init method receives the undertaker instance so metadata can be tracked. Please try this feature out with the https://github.com/phated/undertaker/tree/registry-init branch and let me know how things go. I want to get as many people trying it out as possible before I cut a release. Thanks.

@phated
Copy link
Member

phated commented Aug 10, 2015

Specific commit 21cafaa

@phated
Copy link
Member

phated commented Aug 21, 2015

@mikehaas763 pinging

@phated phated modified the milestone: 1.0.0 Aug 21, 2015
@phated
Copy link
Member

phated commented Aug 21, 2015

I believe this was closed by e7bf5b3 - Please reopen if changing to the init lifecycle hook doesn't solve this problem

@phated phated closed this as completed Aug 21, 2015
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants