Skip to content

Commit

Permalink
feat: update to 3.0.0 stable (#33)
Browse files Browse the repository at this point in the history
  • Loading branch information
codebytere committed Oct 21, 2018
1 parent 2ffa656 commit f2aa153
Show file tree
Hide file tree
Showing 5 changed files with 4,166 additions and 35 deletions.
17 changes: 8 additions & 9 deletions chromedriver.js
@@ -1,23 +1,22 @@
#!/usr/bin/env node

var ChildProcess = require('child_process')
var path = require('path')
const ChildProcess = require('child_process')
const path = require('path')

var command = path.join(__dirname, 'bin', 'chromedriver')
var args = process.argv.slice(2)
var options = {
const command = path.join(__dirname, 'bin', 'chromedriver')
const args = process.argv.slice(2)
const options = {
cwd: process.cwd(),
env: process.env,
stdio: 'inherit'
}

var chromeDriverProcess = ChildProcess.spawn(command, args, options)
const chromeDriverProcess = ChildProcess.spawn(command, args, options)

var killChromeDriver = function () {
const killChromeDriver = () => {
try {
chromeDriverProcess.kill()
} catch (ignored) {
}
} catch (ignored) {}
}

process.on('exit', killChromeDriver)
Expand Down
22 changes: 11 additions & 11 deletions download-chromedriver.js
@@ -1,12 +1,12 @@
var fs = require('fs')
var path = require('path')
var electronDownload = require('electron-download')
var extractZip = require('extract-zip')
var versionToDownload = require('./package').version
const fs = require('fs')
const path = require('path')
const electronDownload = require('electron-download')
const extractZip = require('extract-zip')
const versionToDownload = require('./package').version

function download (version, callback) {
electronDownload({
version: version,
version,
chromedriver: true,
platform: process.env.npm_config_platform,
arch: process.env.npm_config_arch,
Expand All @@ -17,20 +17,20 @@ function download (version, callback) {

function processDownload (err, zipPath) {
if (err != null) throw err
extractZip(zipPath, {dir: path.join(__dirname, 'bin')}, function (error) {
extractZip(zipPath, {dir: path.join(__dirname, 'bin')}, error => {
if (error != null) throw error
if (process.platform !== 'win32') {
fs.chmod(path.join(__dirname, 'bin', 'chromedriver'), '755', function (error) {
fs.chmod(path.join(__dirname, 'bin', 'chromedriver'), '755', error => {
if (error != null) throw error
})
}
})
}

download(versionToDownload, function (err, zipPath) {
download(versionToDownload, (err, zipPath) => {
if (err) {
var versionSegments = versionToDownload.split('.')
var baseVersion = versionSegments[0] + '.' + versionSegments[1] + '.0'
const parts = versionToDownload.split('.')
const baseVersion = `${parts[0]}.${parts[1]}.0`
download(baseVersion, processDownload)
} else {
processDownload(err, zipPath)
Expand Down

0 comments on commit f2aa153

Please sign in to comment.