webdriver-manager
Advanced tools
Comparing version 5.1.0 to 5.2.0
@@ -28,3 +28,3 @@ var fs = require('fs'); | ||
*/ | ||
var spawnCommand = function(command, args) { | ||
var spawnCommand = function(command, args, log) { | ||
var win32 = process.platform === 'win32'; | ||
@@ -41,3 +41,4 @@ var winCommand = win32 ? 'cmd' : command; | ||
child.stderr.on('data', function (data) { | ||
process.stdout.write(data); | ||
log(data); | ||
if (/Started SocketListener/g.test(data.toString()) && !started) { | ||
@@ -129,6 +130,11 @@ eventEmitter.emit('ready', child); | ||
function WebdriverManager(out_dir, proxy) { | ||
function WebdriverManager(out_dir, proxy, quiet) { | ||
this.out_dir = out_dir || SELENIUM_DIR; | ||
this.proxy = proxy; | ||
this.quiet = quiet; | ||
// this.log = this.quiet ? function () {} : process.stdout.write.bind(process.stdout); | ||
this.log = this.quiet ? function () {} : console.log.bind(console); | ||
this.errorLog = this.quiet ? function () {} : console.error.bind(console); | ||
// Create directory if it does not exist | ||
@@ -186,6 +192,6 @@ if (!fs.existsSync(this.out_dir) || !fs.statSync(this.out_dir).isDirectory()) { | ||
}); | ||
console.log('Updating ' + bin.name); | ||
this.log('Updating ' + bin.name); | ||
var url = bin.url(); | ||
if (!url) { | ||
console.error(bin.name + ' is not available for your system.'); | ||
that.errorLog(bin.name + ' is not available for your system.'); | ||
return; | ||
@@ -199,3 +205,3 @@ } | ||
} else { | ||
console.log(bin.name + ' is up to date.'); | ||
this.log(bin.name + ' is up to date.'); | ||
if (opt_callback) { | ||
@@ -209,5 +215,6 @@ opt_callback(path.join(that.out_dir, bin.filename)); | ||
WebdriverManager.prototype._httpGetFile = function(fileUrl, fileName, callback) { | ||
console.log('downloading ' + fileUrl + '...'); | ||
this.log('downloading ' + fileUrl + '...'); | ||
var filePath = path.join(this.out_dir, fileName); | ||
var file = fs.createWriteStream(filePath); | ||
var self = this; | ||
@@ -220,11 +227,11 @@ var options = { | ||
fs.unlink(filePath); | ||
console.error('Error: Got error ' + error + ' from ' + fileUrl); | ||
self.errorLog('Error: Got error ' + error + ' from ' + fileUrl); | ||
}).on('response', function(response) { | ||
if (response.statusCode !== 200) { | ||
fs.unlink(filePath); | ||
console.error('Error: Got code ' + response.statusCode + ' from ' + fileUrl); | ||
self.errorLog('Error: Got code ' + response.statusCode + ' from ' + fileUrl); | ||
return; | ||
} | ||
}).pipe(file).on('close', function() { | ||
console.log(fileName + ' downloaded to ' + filePath); | ||
self.log(fileName + ' downloaded to ' + filePath); | ||
if (callback) { | ||
@@ -256,4 +263,4 @@ callback(filePath); | ||
if (!this.binaries.standalone.exists) { | ||
console.error('Selenium Standalone is not present. Install with ' + | ||
'webdriver-manager update --standalone'); | ||
self.errorLog('Selenium Standalone is not present. Install with ' + | ||
'webdriver-manager update --standalone'); | ||
process.exit(1); | ||
@@ -273,6 +280,7 @@ } | ||
} | ||
var selenium = spawnCommand('java', args); | ||
console.log('selenium.pid: ' + selenium.pid); | ||
var out = this.quiet ? function () {} : process.stdout.write.bind(process.stdout); | ||
var selenium = spawnCommand('java', args, out); | ||
self.log('selenium.pid: ' + selenium.pid); | ||
selenium.on('exit', function(code) { | ||
console.log('Selenium Standalone has exited with code ' + code); | ||
self.log('Selenium Standalone has exited with code ' + code); | ||
process.exit(code); | ||
@@ -289,3 +297,3 @@ }); | ||
process.on('SIGINT', function() { | ||
console.log('Staying alive until the Selenium Standalone process exits'); | ||
self.log('Staying alive until the Selenium Standalone process exits'); | ||
}); | ||
@@ -326,3 +334,5 @@ | ||
console.log('Attempting to shut down selenium nicely'); | ||
var self = this; | ||
self.log('Attempting to shut down selenium nicely'); | ||
var url = util.format( | ||
@@ -379,3 +389,3 @@ 'http://localhost:%d/selenium-server/driver/?cmd=shutDownSeleniumServer', | ||
// windows: chromedriver.exe | ||
console.log(filename, that.out_dir); | ||
that.log(filename, that.out_dir); | ||
zip.extractAllTo(that.out_dir); | ||
@@ -382,0 +392,0 @@ filename = path.join(that.out_dir, 'chromedriver'); |
{ | ||
"name": "webdriver-manager", | ||
"version": "5.1.0", | ||
"version": "5.2.0", | ||
"description": "Protactor's webdriver-manager as a standalone Node.js module.", | ||
@@ -5,0 +5,0 @@ "dependencies": { |
@@ -9,2 +9,5 @@ # Webdriver Manager | ||
### [5.2.0] - 2015-05-19 | ||
- Added `WebdriverManager` constructor third argument: `quiet` (default: `false`). Supresses writing to both `stdout` and `stderr`. | ||
### [5.1.0] - 2015-05-18 | ||
@@ -11,0 +14,0 @@ - Added optional callback to `start(options, cb)` method. `cb` will be executed once selenium server has started. |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
16829
378
30