Skip to content

Commit

Permalink
Merge pull request #59 from erickzhao/chore/migrate-get
Browse files Browse the repository at this point in the history
chore: upgrade dependencies to latest
  • Loading branch information
John Kleinschmidt committed Apr 6, 2020
2 parents d25a3ac + b244950 commit ab6cd41
Show file tree
Hide file tree
Showing 5 changed files with 528 additions and 779 deletions.
18 changes: 14 additions & 4 deletions .circleci/config.yml
Expand Up @@ -7,7 +7,7 @@ jobs:
install-test-linux:
docker:
# specify the version you desire here
- image: circleci/node:9-browsers
- image: circleci/node:10

# Specify service dependencies here if necessary
# CircleCI maintains a library of pre-built images
Expand Down Expand Up @@ -43,14 +43,26 @@ jobs:
xcode: "9.0"
steps:
- checkout

# Download and cache dependencies
- restore_cache:
keys:
- v1-mac-dependencies-{{ checksum "package.json" }}
# fallback to using the latest cache if no exact match is found
- v1-mac-dependencies-

# Lock into Node.js version
- run:
name: Install Node.js
command: |
curl -o- https://raw.githubusercontent.com/nvm-sh/nvm/v0.35.3/install.sh | bash
export NVM_DIR="$HOME/.nvm"
[ -s "$NVM_DIR/nvm.sh" ] && \. "$NVM_DIR/nvm.sh"
nvm install v10.19.0
nvm alias default v10.19.0
echo 'export NVM_DIR=${HOME}/.nvm' >> $BASH_ENV
echo "[ -s '${NVM_DIR}/nvm.sh' ] && . '${NVM_DIR}/nvm.sh'" >> $BASH_ENV
- run: node --version
- run: npm --version
- run: npm install

- save_cache:
Expand All @@ -59,8 +71,6 @@ jobs:
key: v1-mac-dependencies-{{ checksum "package.json" }}

# run tests!
- run: node --version
- run: npm --version
- run: npm test

workflows:
Expand Down
2 changes: 1 addition & 1 deletion appveyor.yml
Expand Up @@ -7,7 +7,7 @@ branches:
- master

environment:
nodejs_version: "6"
nodejs_version: "10"

cache:
- node_modules -> package.json
Expand Down
50 changes: 26 additions & 24 deletions download-chromedriver.js
@@ -1,38 +1,40 @@
const fs = require('fs')
const { promises: fs } = require('fs')
const path = require('path')
const electronDownload = require('electron-download')
const { downloadArtifact } = require('@electron/get')
const extractZip = require('extract-zip')
const versionToDownload = require('./package').version

function download (version, callback) {
electronDownload({
function download (version) {
return downloadArtifact({
version,
chromedriver: true,
artifactName: 'chromedriver',
platform: process.env.npm_config_platform,
arch: process.env.npm_config_arch,
strictSSL: process.env.npm_config_strict_ssl === 'true',
rejectUnauthorized: process.env.npm_config_strict_ssl === 'true',
quiet: ['info', 'verbose', 'silly', 'http'].indexOf(process.env.npm_config_loglevel) === -1
}, callback)
})
}

function processDownload (err, zipPath) {
if (err != null) throw err
extractZip(zipPath, { dir: path.join(__dirname, 'bin') }, error => {
if (error != null) throw error
async function attemptDownload (version) {
try {
const targetFolder = path.join(__dirname, 'bin')
const zipPath = await download(version)
await extractZip(zipPath, { dir: targetFolder })
if (process.platform !== 'win32') {
fs.chmod(path.join(__dirname, 'bin', 'chromedriver'), '755', error => {
if (error != null) throw error
})
await fs.chmod(path.join(targetFolder, 'chromedriver'), 0o755)
}
})
}

download(versionToDownload, (err, zipPath) => {
if (err) {
const parts = versionToDownload.split('.')
} catch (err) {
// attempt to fall back to semver minor
const parts = version.split('.')
const baseVersion = `${parts[0]}.${parts[1]}.0`
download(baseVersion, processDownload)
} else {
processDownload(err, zipPath)

// don't recurse infinitely
if (baseVersion === version) {
throw err
} else {
await attemptDownload(baseVersion)
}
}
})
}

attemptDownload(versionToDownload)

0 comments on commit ab6cd41

Please sign in to comment.