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

Detect whether Grunt has run once #1600

Closed
ArmorDarks opened this issue Jul 24, 2017 · 4 comments
Closed

Detect whether Grunt has run once #1600

ArmorDarks opened this issue Jul 24, 2017 · 4 comments

Comments

@ArmorDarks
Copy link

I wonder, is there any way to detect when Grunt has run once?

In docs said that Grunt supports adding events, but doesn't emit any events itself. That's quite unfortunate, since it could help this issue.

Just to be more clear, I need to start another emitter, but it should happen only once, during init of Grunt. Right now any edits will invoke Grunt again via grunt-contrib-watch, thus reinitializing emitter too.

I know that I can store value that it already had run once somewhere else in cache, but it would be much better to avoid disk operations. And right now there seems to be no way to store any persistent data in-memory.

@shama
Copy link
Member

shama commented Jul 24, 2017

This is because grunt-contrib-watch by default runs tasks in a new process. You can set spawn: false to have it run tasks in the same process.

@shama shama closed this as completed Jul 24, 2017
@ArmorDarks
Copy link
Author

ArmorDarks commented Jul 24, 2017

Thanks for reply!

Yes, I know that it launches new process, but spawn: false in some cases can be undesired. I had to clarify that in my first post — is it possible somehow to overcome this issue without specifying spawn: false or relying on disk operations? Maybe I'm missing something obvious?

@ArmorDarks
Copy link
Author

Just a reminder why spawn: false as of right now unusable in complex projects: gruntjs/grunt-contrib-watch#510

@shama
Copy link
Member

shama commented Jul 24, 2017

Feel free to submit an rfc if you have an idea for a better API you would like to implement.

I'm not sure what your use case is. grunt-contrib-watch can either spawn tasks or not spawn tasks. If that isn't sufficient, one could implement their own task that watches files if further customization is needed by using gaze, chokidar or many there is a better watch lib out there now.

Re: gruntjs/grunt-contrib-watch#510 sometimes an issue is really just a misunderstanding. Glancing at that issue, it looks like they are misunderstanding what spawn: false actually does. Unfortunately I don't have the time to look into their issue and help them resolve it or make changes that might better accommodate their use case though.

I use grunt-contrib-watch just fine on many complex projects.

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