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

this.remote async execution order #903

Closed
julkue opened this issue Feb 6, 2016 · 21 comments
Closed

this.remote async execution order #903

julkue opened this issue Feb 6, 2016 · 21 comments

Comments

@julkue
Copy link

julkue commented Feb 6, 2016

A part of a yeoman generator:

loadingFiles: function(){
    var done = this.async();
    this.remote('xyz', 'xyz', 'master', function(err, remote){
        remote.directory('src', 'src');
        done();
    }, true);
},
something: function(){
    this.log("FINISHING");
},
finishing: function(){
    this.installDependencies();
}

will print the following:

Fetching...
FINISHING
I'm all done. Running npm...
create "...."
....

Fetching... and create "..." is related to this.remote.
So what I expect is:

Fetching
create "..."
FINISHING
I'm all done. Running npm...

What is going on here?

@SBoudrias
Copy link
Member

What version are you on?

@julkue
Copy link
Author

julkue commented Feb 6, 2016

NodeJS: 4.2.2
Yo: 1.6.0

@SBoudrias
Copy link
Member

I meant yeoman-generator version.

@julkue
Copy link
Author

julkue commented Feb 7, 2016

Sorry, in Germany it was late :bowtie:
yeoman-generator: 0.22.5
Project reference

@benitolopez
Copy link

Same issue here. yeoman-generator v.0.22.5

@julkue
Copy link
Author

julkue commented Feb 13, 2016

@SBoudrias bump

@benitolopez
Copy link

Personally I’ve solved the issue using an NPM module instead of the built-in remote utility. And I agree with @SBoudrias (#766 (comment)) regarding the remote and fetch utilities: those tasks can be accomplished with other NPM modules.

By the way, it's just my opinion :)

@julkue
Copy link
Author

julkue commented Feb 13, 2016

@benitolopez What npm module?

I don't think it is a good idea to turn off using built in functions instead of debugging them. Many people require same things so I am glad that the built in utilities exist and I don't need to worry about vendor things.

@benitolopez
Copy link

@julmot download and download-status

@julkue
Copy link
Author

julkue commented Feb 13, 2016

@benitolopez Thanks for letting me know. How are you handling remote fetches where you only want to download a single file or directory, not the entire zip?

@benitolopez
Copy link

I'm using that module to download the whole zip so I've never tried with a single file. But the example in the download page downloads a zip and a single file. Just delete the "zip" line.

@julkue
Copy link
Author

julkue commented Feb 15, 2016

@benitolopez I can confirm it shows an example to download a single file. However, since GitHub doesn't provide download links for single folders of a GitHub repo I would need to download the entire repo, extract it into a temporary folder and copy the things from there. Seems to be not a really profit instead of debugging this.remote.

@SBoudrias
Copy link
Member

@julmot I'll get to it, but I'm fairly certain it's an issue with your code specifically as you're the only one who reported this issue - or any issues regarding asynchronous execution. As such, it's not really to the top of my todo list currently.

If you can create a reducer test case generator reproducing this issue, it'll help me look into it faster. Also, it might just help you figure out the issue if it's effectively related to your own code.

@julkue
Copy link
Author

julkue commented Feb 15, 2016

@SBoudrias on your wish

Demo generator

Here is a ZIP containing a demo generator:
generator-demo.zip

Steps to reproduce

All you need to do is extract it and run $ npm link inside ./app/. Then create a temporary folder and run $ yo demo inside.

Expected behaviour

This will output:

log

I have framed the wrong part. All remote related logs should be after the Fetching statements.

@SBoudrias
Copy link
Member

Oh, I totally misunderstood your issue.

The create x logs are all shown at the end of the process because any files operations happens on a memory store. As so, they're not commited to the user disk until the generator is done running. So effectively, all file writes happens all at once at the end of the process.

@julkue
Copy link
Author

julkue commented Feb 16, 2016

@SBoudrias Thanks for letting me know.
Even if yeoman-generator writes files to a buffer and only stores them in the destination if the generator is finished, then the log should still be in the same order as the commands were called?
If this is not possible due to internal reasons, is there a way to hide those "create" statements for better understanding?

@SBoudrias
Copy link
Member

@julmot what is really the issue you want to fix?

@julkue
Copy link
Author

julkue commented Feb 16, 2016

@SBoudrias I would like to have a console output that shows the tasks in the same order as they are processed in the background. If an action like remote is handled before this.installDependencies() then this should be printed before. With the current log I'm associating a wrong behaviour.

@SBoudrias
Copy link
Member

Hey, you could manually use this.log(), but we have no plans to change the way we log stuff than in the actual real order they are happening.

@julkue
Copy link
Author

julkue commented Mar 11, 2016

I find the current log behavior confusing and I think others too. Is there a way to hide those "create x" statements?

@SBoudrias
Copy link
Member

No. We haven't had complaint from end users and we want to keep the experience consistent across our ecosystem.

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

3 participants