I'm working on a Grunt task that opens one or more pages/urls up (e.g. the demo pages) in phantomjs and does various performance and integration tests (no uncaught exceptions or 404 errors etc.).
The way the events are emitted makes it difficult to keep context, so one is basically required to, when inside a multitask, attach the event handlers in the outer scope.
However when using something like async.forEachLimit to iterate through the pages, it's near impossible to deal with the events.
In theory I could move require( 'grunt-lib-phantomjs' ).init( grunt ); and the event handlers to inside the main work loop. However this still poses issues with the output.
It would cut down the execution time a lot if I could use async.forEachLimit( urls, 3, .. so that we'd run three of them in parallel. I'm curious if other people have run into this.
I'm considering to do it and solve the output issue by buffering it in a wrapper object instead of using the grunt.log methods directly (e.g. mylog = { text: '', error: '', ok: '', dirobjects: [] }) and pass it on to the grunt.log methods at the end of each iteration.
I'm working on a Grunt task that opens one or more pages/urls up (e.g. the demo pages) in phantomjs and does various performance and integration tests (no uncaught exceptions or 404 errors etc.).
The way the events are emitted makes it difficult to keep context, so one is basically required to, when inside a multitask, attach the event handlers in the outer scope.
However when using something like
async.forEachLimit
to iterate through the pages, it's near impossible to deal with the events.In theory I could move
require( 'grunt-lib-phantomjs' ).init( grunt );
and the event handlers to inside the main work loop. However this still poses issues with the output.Abstract example:
It would cut down the execution time a lot if I could use
async.forEachLimit( urls, 3, ..
so that we'd run three of them in parallel. I'm curious if other people have run into this.I'm considering to do it and solve the output issue by buffering it in a wrapper object instead of using the
grunt.log
methods directly (e.g.mylog = { text: '', error: '', ok: '', dirobjects: [] }
) and pass it on to thegrunt.log
methods at the end of each iteration.