tasks/springroll.js
function downloadArchive(id, call, options, done)
	{
		grunt.log.write('Downloading '.gray + id.yellow + ' ... '.gray);

		request(call, function(err, response, body)
		{
			if (err) return done(err);

			var result = JSON.parse(body);

			if (!result.success) 
			{
				return done(result.error + ' with game "' + id + '"');
			}

			if (options.json)
			{
				grunt.log.write('Writing json ... '.gray);

				var writeStream = fs.createWriteStream(path.join(options.dest, id + '.json'));
				writeStream.write(JSON.stringify(result.data, null, options.debug ? "\t":""));
				writeStream.end();
			}

			grunt.log.write('Installing ... '.gray);

			this.get(result.data.url).run(function(err, files)
			{
				if (err) 
				{
					return done('Unable to download archive for game "' + id + '"');
				}
				grunt.log.writeln('Done.'.green);
				done(null, files);
			});
		}
		.bind(this));
	}
function downloadArchive(id, call, options, done)
	{
		grunt.log.write('Downloading '.gray + id.yellow + ' ... '.gray);

		request(call, function(err, response, body)
		{
			if (err) return done(err);

			var result = JSON.parse(body);

			if (!result.success) 
			{
				return done(result.error + ' with game "' + id + '"');
			}

			if (options.json)
			{
				grunt.log.write('Writing json ... '.gray);

				var writeStream = fs.createWriteStream(path.join(options.dest, id + '.json'));
				writeStream.write(JSON.stringify(result.data, null, options.debug ? "\t":""));
				writeStream.end();
			}

			grunt.log.write('Installing ... '.gray);

			this.get(result.data.url).run(function(err, files)
			{
				if (err) 
				{
					return done('Unable to download archive for game "' + id + '"');
				}
				grunt.log.writeln('Done.'.green);
				done(null, files);
			});
		}
		.bind(this));
	}
function downloadArchive ( id , call , options , done ) { grunt . log . write ( 'Downloading ' . gray + id . yellow + ' ... ' . gray ) ; request ( call , function ( err , response , body ) { if ( err ) return done ( err ) ; var result = JSON . parse ( body ) ; if ( ! result . success ) { return done ( result . error + ' with game "' + id + '"' ) ; } if ( options . json ) { grunt . log . write ( 'Writing json ... ' . gray ) ; var writeStream = fs . createWriteStream ( path . join ( options . dest , id + '.json' ) ) ; writeStream . write ( JSON . stringify ( result . data , null , options . debug ? "\t" : "" ) ) ; writeStream . end ( ) ; } grunt . log . write ( 'Installing ... ' . gray ) ; this . get ( result . data . url ) . run ( function ( err , files ) { if ( err ) { return done ( 'Unable to download archive for game "' + id + '"' ) ; } grunt . log . writeln ( 'Done.' . green ) ; done ( null , files ) ; } ) ; } . bind ( this ) ) ; }
Handle the request
Handle the request