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

Win/Linux release will not resolve when task finishes #25

Closed
create-renegr opened this issue Oct 7, 2013 · 12 comments
Closed

Win/Linux release will not resolve when task finishes #25

create-renegr opened this issue Oct 7, 2013 · 12 comments

Comments

@create-renegr
Copy link

... and this causes to not execute any other grunt task in line

Please add

releaseDone.resolve(type);

in compress.js after line 87

Thanks in advance!

Or it maybe relates to another bug, since the zip file and the executable seem not to be concatenated (at least for win).

P.S.: Thanks for creating this nice little grunt task!

@steffenmllr
Copy link
Contributor

It should be resolved here: https://github.com/mllrsohn/grunt-node-webkit-builder/blob/master/tasks/lib/compress.js#L68-L70 but I'll take a look at it

@create-renegr
Copy link
Author

I played around with your code, inside compress.js:

        ws.on('close', function() {
            grunt.log.writeln('ws.close event fired');
            releaseDone.resolve(type);
        });

        if(type === 'mac') {
            // On osx just copy to the target location
            zipStream.pipe(ws);
        } else {
            // on windows and linux cat the node-webkit with the nw archive
            nwpath_rs = fs.createReadStream(nwpath);

            nwpath_rs.on('error', function(err) {
                grunt.fail.fatal(err);
            });

            nwpath_rs.on('end', function(){
                zipStream.on('end', function() {
                    grunt.log.writeln('Resolving/finishing');
                    releaseDone.resolve(type);
                });
                grunt.log.writeln(zipPath);
                zipStream.pipe(ws);
            });

            nwpath_rs.pipe(ws, { end: false });
        }

Guess what, the console tells me:

/***/build/releases/*/*.nw
ws.close event fired
Deleting temp zip file

But it never tells me resolving/finishing. The reason why the files are not concatenated? I can't get the final end-Event being fired

Do you have any idea?

@steffenmllr
Copy link
Contributor

Which plattform are you on? Because the concat of the files for win/linux and execution of tasks (before and after) works fine of mac. Here are some more console logs to show the current control flow:

    exports.generateRelease = function(relaseFile, zipPath, type, nwpath) {
        var releaseDone = Q.defer(),
            ws = fs.createWriteStream(relaseFile),
            zipStream = fs.createReadStream(zipPath),
            nwpath_rs;

        ws.on('error', function(err) {
            grunt.fail.fatal(err);
        });

        ws.on('close', function() {
            console.log('4. Writing to the releaseFile Endes -> promise resolved');
            releaseDone.resolve(type);
        });

        zipStream.on('close', function() {
            console.log('3. Reading from the zipStream ends');
        });

        if(type === 'mac') {
            // On osx just copy to the target location
            zipStream.pipe(ws);
        } else {
            // on windows and linux cat the node-webkit with the nw archive
            nwpath_rs = fs.createReadStream(nwpath);

            nwpath_rs.on('error', function(err) {
                grunt.fail.fatal(err);
            });

            nwpath_rs.on('end', function(){
                console.log('2. Reading the .exe/nw file ends, now we pipe in the zip we created');
                zipStream.pipe(ws);
            });

            console.log('1. Piping the .exe at nwpath_rs into a new file and not close the stream');
            nwpath_rs.pipe(ws, { end: false });
        }

        return releaseDone.promise;
    };

@create-renegr
Copy link
Author

I'm on a mac (10.8.5) and I get this (for Mac+Win configuration)

Running "nodewebkit:src" (nodewebkit) task
1. (win) Piping the .exe at nwpath_rs into a new file and not close the stream
3. (win) Reading from the zipStream ends
3. (mac) Reading from the zipStream ends
4. (mac) Writing to the releaseFile Endes -> promise resolved
2. (win) Reading the .exe/nw file ends, now we pipe in the zip we created

As you notice, there is no Done, without errors. as with grunt:clean for example.

Running "clean:releases" (clean) task
Cleaning "./build/releases/"...OK

Done, without errors.

There is something going wrong, because my win file is not concatenated.

@steffenmllr
Copy link
Contributor

There is definitely something wrong, this is my output. Are you running any other task or just node webkit?

1. Piping the .exe at nwpath_rs into a new file and not close the stream(win)
3. Reading from the zipStream ends(mac)
4. Writing to the releaseFile Endes -> promise resolved(mac)
2. Reading the .exe/nw file ends, now we pipe in the zip we created(win)
3. Reading from the zipStream ends(win)
4. Writing to the releaseFile Endes -> promise resolved(win)
>> Created a new release with node-webkit (0.7.5) for win, mac
>> @ /Users/steffen/www_root/opensource/grunt-node-webkit-builder/example/build/releases/nw-demo

Done, without errors.

@create-renegr
Copy link
Author

I'm running it either way. Standalone, and with some other grunt tasks (like clean, right before).
To bad, I don't have a clue yet :-/

What version of node are you using?
Mine is v0.8.23

@create-renegr
Copy link
Author

Version seems to solve the problem. Tried it with v0.11.5 and here is what you get:

Running "nodewebkit:src" (nodewebkit) task
1. (win) Piping the .exe at nwpath_rs into a new file and not close the stream
3. (mac) Reading from the zipStream ends
4. (mac) Writing to the releaseFile Endes -> promise resolved
2. (win) Reading the .exe/nw file ends, now we pipe in the zip we created
3. (win) Reading from the zipStream ends
4. (win) Writing to the releaseFile Endes -> promise resolved
>> Created a new release with node-webkit (0.7.5) for win, mac
...

Done, without errors.

Maybe set a minimum node.js version as dependency :-)

@steffenmllr
Copy link
Contributor

Yeah there were some bugs in earlier versions :) if everything works as expected, please close the issue.

@create-renegr
Copy link
Author

You should set a proper node version as dependency, before the bug is closed. A proper version dependency would help others to not run into the same problem by accident. Does this make sense to you?

(Btw, here's an open bug for the engineStrict bug(?) in npm: https://github.com/isaacs/npm/issues/3672)

@steffenmllr
Copy link
Contributor

Hmm ok I though you meant the version of the plugin and not node - hmm this is basic streaming stuff and should work almost everywhere. Thanks for the report I'll try to test it on 0.8.x and keep the bug open

@create-renegr
Copy link
Author

Actually I meant the version of node, because - at least on my mac - it does not work with node v0.8.23

@create-renegr
Copy link
Author

10times 👍
Thanks for the new release v0.1.11. Can confirm that it works with node 0.8.23 know!

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

2 participants