Beispiel #1
0
		req.on('response', function(res) {
			if (res.statusCode!=200) {
				return callback(new Error("error loading url: "+url+", status: "+res.statusCode));
			}
			var len = parseInt(res.headers['content-length'], 10),
				bar = new appc.progress('  Downloading '+name+' library'.magenta+' [:bar]'+' :percent :etas'.cyan, {
				complete: '=',
				incomplete: ' ',
				width: 50,
				total: len
			}),
			stream = fs.createWriteStream(zf);

			bar.tick(0);

			res.on('data', function(chunk) {
				bar.tick(chunk.length);
				hash.update(chunk);
				stream.write(chunk, encoding='binary');
			});

			res.on('end', function() {
				fs.writeFileSync(verFn,version);
				stream.close();
				process.stdout.clearLine && process.stdout.clearLine();  // clear current text
  				process.stdout.cursorTo && process.stdout.cursorTo(0);  // move cursor to beginning of line
  				process.stdout.write('\n');
				var checkChecksum = hash.digest('hex');
				if (checkChecksum!==checksum) {
					return callback(new Error("Invalid checksum ("+checkChecksum+") received, expected ("+checksum+") for "+url));
				}
				log.info('extracting zip contents');
				appc.zip.unzip(zf,zipdir,function(err){
					log.debug('unzip completed, contents should be in',zipdir);
					fs.unlink(zf,callback);
				});
			});
		});
Beispiel #2
0
	req.on('response', function (req) {
		var total = parseInt(req.headers['content-length']),
			bar = new appc.progress('  :paddedPercent [:bar] :etas', {
				complete: '='.cyan,
				incomplete: '.'.grey,
				width: 40,
				total: total
			});
		
		req.on('data', function (buffer) {
			bar.tick(buffer.length);
		});
		
		tempStream.on('close', function (e) {
			bar.tick(total);
			logger.log('\n');
			extractSDK(logger, tempName, version, env, onSuccess);
		});
	});
Beispiel #3
0
		tempStream.on('close', function (e) {
			bar.tick(total);
			logger.log('\n');
			extractSDK(logger, tempName, version, env, onSuccess);
		});
Beispiel #4
0
		req.on('data', function (buffer) {
			bar.tick(buffer.length);
		});
Beispiel #5
0
			res.on('data', function(chunk) {
				bar.tick(chunk.length);
				hash.update(chunk);
				stream.write(chunk, encoding='binary');
			});