Software zum Installieren eines Smart-Mirror Frameworks , zum Nutzen von hochschulrelevanten Informationen, auf einem Raspberry-Pi.
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

download-chromedriver.js 1.4KB

12345678910111213141516171819202122232425262728293031323334353637383940414243
  1. const { promises: fs } = require('fs')
  2. const path = require('path')
  3. const { downloadArtifact } = require('@electron/get')
  4. const extractZip = require('extract-zip')
  5. const versionToDownload = require('./package').version
  6. function download (version) {
  7. return downloadArtifact({
  8. version,
  9. artifactName: 'chromedriver',
  10. force: process.env.force_no_cache === 'true',
  11. cacheRoot: process.env.electron_config_cache,
  12. platform: process.env.npm_config_platform,
  13. arch: process.env.npm_config_arch,
  14. rejectUnauthorized: process.env.npm_config_strict_ssl === 'true',
  15. quiet: ['info', 'verbose', 'silly', 'http'].indexOf(process.env.npm_config_loglevel) === -1
  16. })
  17. }
  18. async function attemptDownload (version) {
  19. try {
  20. const targetFolder = path.join(__dirname, 'bin')
  21. const zipPath = await download(version)
  22. await extractZip(zipPath, { dir: targetFolder })
  23. const platform = process.env.npm_config_platform || process.platform
  24. if (platform !== 'win32') {
  25. await fs.chmod(path.join(targetFolder, 'chromedriver'), 0o755)
  26. }
  27. } catch (err) {
  28. // attempt to fall back to semver minor
  29. const parts = version.split('.')
  30. const baseVersion = `${parts[0]}.${parts[1]}.0`
  31. // don't recurse infinitely
  32. if (baseVersion === version) {
  33. throw err
  34. } else {
  35. await attemptDownload(baseVersion)
  36. }
  37. }
  38. }
  39. attemptDownload(versionToDownload)