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

Listening for bower events, while using yeoman in non cli environment #529

Closed
apdarshan opened this issue Apr 10, 2014 · 7 comments
Closed

Comments

@apdarshan
Copy link

Thanks for abstracting out Base object for non-cli support. I am building an extension for Adobe brackets with my yeoman generator. My concern is How/Where do I listen for bower log, errror, end events.

    _installBower: function (cb) {
        this.log("Running bower install...");
        /*reads bower.json and installs*/
        bower.commands.install([], {}, {directory : "./", cwd: process.cwd()}).on('error', function (error) {
            this.log("BOWER error::" + JSON.stringify(error));
            cb();
        }.bind(this)).on('log', function (log) {
            this.log("BOWER LOG::" + JSON.stringify(log));
            this.emit("log", log); // TODO::
        }.bind(this)).on('end', function (installed) {
            this.log("BOWER END::" + JSON.stringify(installed));
            cb();
        }.bind(this));
    },

    bowerInstallHelper: function(){
        if (!this.options['skip-install']) {
            var cb = this.async();
            this._installBower(cb);
        }
    }

As every Adobe Brackets user may not have yeoman/bower installed globally, I have bower installed locally using generator's package.json and requiring it in generator-myframewrlk/app/index.js.

I have emit method defined in my Adapter as below,

 MyAwesomeAdapter.prototype.emit = function(event, data) {
    console.log(event); // not coming here
    var handlers = this.eventHandlers[event];
    handlers.forEach(function(handler, i) {
        handler(data);
    });
};
@SBoudrias
Copy link
Member

Hi, the issue is there's no emit method on an Adapter: https://github.com/yeoman/generator/blob/master/lib/env/adapter.js

What would you like exposed from the bower API? (And does bower expose it through a programmatic API?)

@apdarshan
Copy link
Author

@SBoudrias I have my own adapter with emit method defined in it, as per this wiki and #383

What would you like exposed from the bower API? (And does bower expose it through a programmatic API?)

Yes bower fires below events, I am getting below logs.

bower.commands.install([], {}, {directory : "./", cwd: process.cwd()}).on('error', function (error) {
            this.log("BOWER error::" + JSON.stringify(error));
        }.bind(this)).on('log', function (log) {
            this.log("BOWER LOG::" + JSON.stringify(log));
        }.bind(this)).on('end', function (installed) {
            this.log("BOWER END::" + JSON.stringify(installed));
        }.bind(this));

I just need to get notified(in my adapter) whenever bower log, error & end events occurs. @artoale

@SBoudrias
Copy link
Member

What I mean is that you can define an emit method, but the Yeoman core doesn't interface its internal emit to your Adapter emit method.

@apdarshan
Copy link
Author

Yes thats what I needed @SBoudrias.

@apdarshan
Copy link
Author

How about this? in env

generator.on('log', this.adapter.emit.bind(this.adapter, "log"));
generator.on('error', this.adapter.emit.bind(this.adapter, "error"));
generator.on('end', this.adapter.emit.bind(this.adapter, "end"));

@SBoudrias
Copy link
Member

We need to write down an ideal API to resolve this issue and then make it actionable so someone can really fix it.

@github-actions
Copy link
Contributor

github-actions bot commented Jan 2, 2020

This issue is stale because it has been open 15 days with no activity. Remove stale label or comment or this will be closed in 5 days

@github-actions github-actions bot added the stale label Jan 2, 2020
@github-actions github-actions bot closed this as completed Jan 8, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants