| 1 |
const child_process = require('child_process'); |
| 2 |
const fs = require('fs'); |
| 3 |
|
| 4 |
function set_env(name, val) { |
| 5 |
fs.appendFileSync(process.env['GITHUB_ENV'], `${name}=${val}\n`) |
| 6 |
} |
| 7 |
|
| 8 |
function fetch(url) { |
| 9 |
child_process.execFileSync('curl', ['--retry', '5', '-LO', url]) |
| 10 |
} |
| 11 |
|
| 12 |
const version = '0.24.0'; |
| 13 |
|
| 14 |
if (process.platform === 'win32') { |
| 15 |
const file = `geckodriver-v${version}-win64.zip`; |
| 16 |
fetch(`https://github.com/mozilla/geckodriver/releases/download/v${version}/${file}`); |
| 17 |
child_process.execFileSync('unzip', [file]); |
| 18 |
set_env("GECKODRIVER", process.cwd() + '/geckodriver.exe'); |
| 19 |
} else { |
| 20 |
const file = `geckodriver-v${version}-linux64.tar.gz`; |
| 21 |
fetch(`https://github.com/mozilla/geckodriver/releases/download/v${version}/${file}`); |
| 22 |
child_process.execFileSync('tar', ['xf', file]); |
| 23 |
set_env("GECKODRIVER", process.cwd() + '/geckodriver'); |
| 24 |
} |