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

How to detect interruption in a plugin #361

Closed
basarat opened this issue Aug 1, 2014 · 3 comments
Closed

How to detect interruption in a plugin #361

basarat opened this issue Aug 1, 2014 · 3 comments

Comments

@basarat
Copy link

basarat commented Aug 1, 2014

The following don't get called with option spawn:false:

process.on('SIGINT', function () {
    console.log('interrupted!!!!!!!!!!!!'.red);
    process.exit();
});

process.on('exit', function (code) {
    console.log('exit!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!'.red);
});
@basarat
Copy link
Author

basarat commented Aug 1, 2014

basically if I call done from an async task after grunt-contrib-watch thinks its completed it, then grunt-contrib-watch gets completed and exits.

Workaround:

// If grunt-contrib-watch is the current task do not call done
            if (grunt.task.current && grunt.task.current.name == 'watch') {
                return;
            }

@basarat
Copy link
Author

basarat commented Aug 1, 2014

Not ideal. I need some way of knowing if someone called : https://github.com/gruntjs/grunt/blob/155609c39928d530f13d8e4581a27455be995792/lib/util/task.js#L201 on my behalf

@shama
Copy link
Member

shama commented Aug 1, 2014

spawn: false runs everything in the same process context. process.on('exit') is only going to be called when the process exits. The watch is designed to never exit, so it is expected to never be called.

If you need to know when a process exits then you'll need to spawn processes.

@shama shama closed this as completed Aug 1, 2014
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