Skip to content

Commit

Permalink
chore: upgrade extract-zip to v2.0.0
Browse files Browse the repository at this point in the history
  • Loading branch information
erickzhao committed Apr 1, 2020
1 parent 3c22216 commit 1e4599b
Show file tree
Hide file tree
Showing 3 changed files with 57 additions and 107 deletions.
19 changes: 6 additions & 13 deletions download-chromedriver.js
@@ -1,4 +1,4 @@
const fs = require('fs')
const { promises: fs } = require('fs')
const path = require('path')
const { downloadArtifact } = require('@electron/get')
const extractZip = require('extract-zip')
Expand All @@ -15,21 +15,14 @@ function download (version) {
})
}

function processDownload (zipPath) {
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', error => {
if (error != null) throw error
})
}
})
}

async function attemptDownload (version) {
try {
const targetFolder = path.join(__dirname, 'bin')
const zipPath = await download(version)
processDownload(zipPath)
await extractZip(zipPath, { dir: targetFolder })
if (process.platform !== 'win32') {
await fs.chmod(path.join(targetFolder, 'chromedriver'), 0o755)
}
} catch (err) {
// attempt to fall back to semver minor
const parts = version.split('.')
Expand Down
143 changes: 50 additions & 93 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion package.json
Expand Up @@ -15,7 +15,7 @@
"license": "MIT",
"dependencies": {
"@electron/get": "^1.9.0",
"extract-zip": "^1.6.7"
"extract-zip": "^2.0.0"
},
"devDependencies": {
"mocha": "^6.2.0",
Expand Down

0 comments on commit 1e4599b

Please sign in to comment.