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

Provide an option to handle the data event #31

Closed
wants to merge 1 commit into from

Conversation

@qawemlilo
Copy link

@qawemlilo qawemlilo commented Sep 30, 2013

It would be nice if users can create their own custom functions to handle the data event.
I'm executing a command that checks my php files for syntax errors.
I would like to be able parse each output as it comes and check if there are no errors, otherwise exit the process.

Example


---
    exec: {
        test: {
            cmd: "find ./component -name '*.php' -exec php -l {} ;",

            onOutData: function (data) {
                console.log(data);

                if (data.match(/Errors parsing|PHP Parse error/g)) {
                    process.exit(1);
                }
            },

            onErrData: function (data) {
                console.log(data);

                if (data.match(/Errors parsing|PHP Parse error/g)) {
                    process.exit(1);
                }
            }
    }

---
@jharding
Copy link
Owner

@jharding jharding commented Dec 25, 2013

Hmm I'd prefer if this wasn't added to grunt-exec. For the use case you propose, I would suggest just modifying your shell command to look for the parse error itself and exit with 1 if it's found.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Linked issues

Successfully merging this pull request may close these issues.

None yet

2 participants