Skip to content


Subversion checkout URL

You can clone with
Download ZIP


Can we have a sync version while using as node module? #5

vishr opened this Issue · 5 comments

3 participants


No description provided.


Do you really really need it? asciify loads a file off disk to get the font, so making that sync would tie up the event loop while the disk IO occurred. It's usually a bad idea to force node to do things sync style, so I'm keen to avoid endorsing that, and instead keep this module as simple as possible.


The ask is for a sync version along with async and the reason is that my program exists without display the ascii text if there is an error or something similar. I am aware that I can do it in a callback but just thought that it would be nice to have a sync version like we have in the core node library for reading file? I am fine if it's going against the design.


Hi Oli,

I kind of also have a similar need. Though there may be another method to do this (please feel free to suggest as I am a newbie with yo/js). However I am not able to figure this out.

I need to get the return value back to main program.
So essentially trying to do this:

asciify(' ' + _.capitalize(, {font:'slant'}, function (err, res) {
                 this.banner = res;
writeToFile('output.txt', this.banner);

I need the banner value captured so it can be written to a file. This is for a 'yo' generator.
Just to add, there is a lot of logic/code after the capture of banner value so I cannot simply add that to callback.

How do I do this?



@amitjindal did you see

it sets a property with the asciified text when it's available:

...and grunt handles the async issue by providing a done callback function, so the next task waits on asciify to complete, so we can assume the property is available to subsequent tasks.

If that's not relevant, then you could take a peek at one of the other yo generators using it:

and see how they do.


Thanks for the tip. After a few trials I figured it out. Very weird syntax. But now it works.

MyClass.prototype.createBanner = function createBanner(text) {
    var cb = this.async();
    asciify(text, {font:'slant'}, function (err, res) {
        this.banner = res;

Later in the code:

this.createBanner(' ' + _.capitalize(this.baseName));
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Something went wrong with that request. Please try again.