Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Why Yeoman can't perform async callback after exec method?

I'm triyng to perform a async callback in my action after the bowerInstall method is completed (the problem is the same with others methods using exec commands). I need this because without it the next action will be triggered before the method is completed.

     _-----_
    |       |    .--------------------------.
    |--(o)--|    |   Yeoman is frustrated   |
   `---------´   |     Help him please!     |
    ( _´U`_ )    '--------------------------'
    /___A___\
     |  ~  |
   __'.___.'__
 ´   `  |° ´ Y `

The issue is Yeoman doesn't support async callback situated in method callback.

default: {
  installPackage: function () {
    done = this.async();
    this.bowerInstall(this.packageName, function () {
      done();
    });
  },
  nextAction: function () {
    // Do stuff after installPackage is completed.
  }
}

In this case, the bowerInstall method is never triggered and the run loop breaks.

[EDIT] SOLUTION

Like Simon Boudrias said, I can't use an async callback in the install context. I have to put the tasks I want to run after the install in the end context.

install: {
  installPackage: function () {
    this.bowerInstall(this.packageName);
  }
},
end: {
  nextAction: function () {
    // Do stuff after installPackage is completed.
  }
}
like image 766
guduf Avatar asked Apr 01 '26 18:04

guduf


1 Answers

Yeoman installation methods are automatically scheduled during the install task loop.

By using this.async() here, you're deadlocking the process.

This change was documented on the v0.18.0 release. Might be worth it to detail that behavior more explicitly on the install methods documentation -> https://github.com/yeoman/yeoman.io/blob/master/app/authoring/dependencies.md

like image 71
Simon Boudrias Avatar answered Apr 04 '26 09:04

Simon Boudrias