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

Task source is fully (re)loaded each time a task i called ? #522

Closed
MoOx opened this issue Nov 12, 2012 · 3 comments
Closed

Task source is fully (re)loaded each time a task i called ? #522

MoOx opened this issue Nov 12, 2012 · 3 comments

Comments

@MoOx
Copy link

MoOx commented Nov 12, 2012

I've created a project recently based on grunt 0.4.0a & I found something weird after having an issue with grunt-reload.
It seems that since grunt 0.4, the source of a task (tasks/xxx.js) is reloaded each time a task is called.
I' made a stupid test with latest 0.3 & 0.4a and I've different result: I've add a console.log just before my grunt.registerTask()is called. With 0.3, the log ouputs one time, just when I start grunt. With 0.4, the log outputs each time my task is used.
Without asking myself if it's a good evolution or not (I'm new to grunt), who can I store a persistant variable between a task call ? Because on this (live)reload task there is a variable to save the started livereload server.

So with grunt 0.4, how can I update this task to make this object live between task call ?

@shama
Copy link
Member

shama commented Nov 18, 2012

The issue sounds similar to gruntjs/grunt-contrib-watch#12 which was fixed on grunt-contrib-watch v0.1.4. Although not sure about the persistent variable between task. The new watch task spawns tasks as child processes. I'll play around with grunt-reload to be sure it's not an issue with the watch task.

@shama
Copy link
Member

shama commented Nov 18, 2012

This is because of the new watch task. Since the watch spawns tasks as child processes objects won't persist and AFAIK cannot across child processes. I'm not sure about the best way to solve this.

One idea is to modify the watch task to have it's core be a lib. In which other tasks can use to be notified of watch events. This way the grunt-reload task can just run one instance and trigger reload on those events. Using grunt.file.watchFiles or firing watch events is another option. This is somewhat related to gruntjs/grunt-contrib-watch#14.

My grunt-hub task could also benefit from the core watch becoming a lib as well as it duplicates a lot of the functionality in the watch task.

@tkellen
Copy link
Member

tkellen commented Dec 31, 2012

Closing. This discussion belongs over at the watch task.

@tkellen tkellen closed this as completed Dec 31, 2012
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

3 participants