Skip to content

Commit

Permalink
Remove npmconf and bump to 2.27.1
Browse files Browse the repository at this point in the history
Closes #45

Signed-off-by: Giovanni Bassi <giggio@giggio.net>
  • Loading branch information
giggio committed Jan 8, 2017
1 parent 5490713 commit 494e723
Show file tree
Hide file tree
Showing 2 changed files with 39 additions and 48 deletions.
84 changes: 38 additions & 46 deletions install.js
Expand Up @@ -6,7 +6,6 @@ var helper = require('./lib/chromedriver');
var http = require('http');
var https = require('https');
var kew = require('kew');
var npmconf = require('npmconf');
var mkdirp = require('mkdirp');
var path = require('path');
var rimraf = require('rimraf').sync;
Expand Down Expand Up @@ -45,56 +44,47 @@ if (platform === 'linux') {
process.exit(1);
}

npmconf.load(function (err, conf) {
if (err) {
console.log('Error loading npm config');
console.error(err);
process.exit(1);
return;
}
var tmpPath = findSuitableTempDirectory();
var downloadedFile = '';
var promise = kew.resolve(true);

var tmpPath = findSuitableTempDirectory(conf);
var downloadedFile = '';
var promise = kew.resolve(true);

promise = promise.then(function () {
if (chromedriver_version === 'LATEST')
return getLatestVersion(getRequestOptions(conf, cdnUrl + '/LATEST_RELEASE'));
});
promise = promise.then(function () {
if (chromedriver_version === 'LATEST')
return getLatestVersion(getRequestOptions(cdnUrl + '/LATEST_RELEASE'));
});

// Start the install.
promise = promise.then(function () {
downloadUrl = util.format(downloadUrl, chromedriver_version, platform);
var fileName = downloadUrl.split('/').pop();
downloadedFile = path.join(tmpPath, fileName);
console.log('Downloading', downloadUrl);
console.log('Saving to', downloadedFile);
return requestBinary(getRequestOptions(conf, downloadUrl), downloadedFile);
});
// Start the install.
promise = promise.then(function () {
downloadUrl = util.format(downloadUrl, chromedriver_version, platform);
var fileName = downloadUrl.split('/').pop();
downloadedFile = path.join(tmpPath, fileName);
console.log('Downloading', downloadUrl);
console.log('Saving to', downloadedFile);
return requestBinary(getRequestOptions(downloadUrl), downloadedFile);
});

promise.then(function () {
return extractDownload(downloadedFile, tmpPath);
promise.then(function () {
return extractDownload(downloadedFile, tmpPath);
})
.then(function () {
return copyIntoPlace(tmpPath, libPath);
})
.then(function () {
return copyIntoPlace(tmpPath, libPath);
})
.then(function () {
return fixFilePermissions();
})
.then(function () {
console.log('Done. ChromeDriver binary available at', helper.path);
})
.fail(function (err) {
console.error('ChromeDriver installation failed', err);
process.exit(1);
});
});
.then(function () {
return fixFilePermissions();
})
.then(function () {
console.log('Done. ChromeDriver binary available at', helper.path);
})
.fail(function (err) {
console.error('ChromeDriver installation failed', err);
process.exit(1);
});


function findSuitableTempDirectory(npmConf) {
function findSuitableTempDirectory() {
var now = Date.now();
var candidateTmpDirs = [
process.env.TMPDIR || npmConf.get('tmp'),
process.env.TMPDIR || process.env.npm_config_tmp,
'/tmp',
path.join(process.cwd(), 'tmp')
];
Expand All @@ -118,9 +108,11 @@ function findSuitableTempDirectory(npmConf) {
}


function getRequestOptions(conf, downloadPath) {
function getRequestOptions(downloadPath) {
var options = url.parse(downloadUrl);
var proxyUrl = options.protocol === 'https:' ? conf.get('https-proxy') : conf.get('proxy');
var proxyUrl = options.protocol === 'https:'
? process.env.npm_config_https_proxy
: (process.env.npm_config_proxy || process.env.npm_config_http_proxy);
if (proxyUrl) {
options = url.parse(proxyUrl);
options.path = downloadPath;
Expand Down Expand Up @@ -282,4 +274,4 @@ function fixFilePermissions() {
fs.chmodSync(helper.path, '755');
}
}
}
}
3 changes: 1 addition & 2 deletions package.json
@@ -1,6 +1,6 @@
{
"name": "chromedriver",
"version": "2.27.0",
"version": "2.27.1",
"keywords": [
"chromedriver",
"selenium"
Expand Down Expand Up @@ -33,7 +33,6 @@
"adm-zip": "^0.4.7",
"kew": "^0.5.0",
"mkdirp": "^0.5.0",
"npmconf": "^2.1.1",
"rimraf": "^2.0.3"
}
}

0 comments on commit 494e723

Please sign in to comment.