electron-chromedriver
Advanced tools
Comparing version
@@ -7,2 +7,29 @@ const { promises: fs } = require('fs') | ||
// Refs https://github.com/electron/fiddle-core/blob/1ee2d2737f23fd1012917a249a9444b6db89f1d8/src/versions.ts#L47-L57 | ||
function compareVersions (a, b) { | ||
const l = a.compareMain(b) | ||
if (l) return l | ||
// Electron's approach is nightly -> other prerelease tags -> stable, | ||
// so force `nightly` to sort before other prerelease tags. | ||
const [prea] = a.prerelease | ||
const [preb] = b.prerelease | ||
if (prea === 'nightly' && preb !== 'nightly') return -1 | ||
if (prea !== 'nightly' && preb === 'nightly') return 1 | ||
return a.comparePre(b) | ||
} | ||
// Refs https://github.com/electron/fiddle-core/blob/1ee2d2737f23fd1012917a249a9444b6db89f1d8/src/versions.ts#L152-L160 | ||
function getLatestStable (releases) { | ||
const { parse: semverParse } = require('semver') | ||
const semvers = releases.map(({ version }) => semverParse(version)).filter((sem) => Boolean(sem)) | ||
semvers.sort((a, b) => compareVersions(a, b)) | ||
let stable | ||
for (const ver of semvers.values()) { | ||
if (ver.prerelease.length === 0) { | ||
stable = ver | ||
} | ||
} | ||
return stable | ||
} | ||
function download (version) { | ||
@@ -22,2 +49,14 @@ return downloadArtifact({ | ||
async function attemptDownload (version) { | ||
// Fall back to latest stable if there is not a stamped version, for tests | ||
if (version === '0.0.0-development') { | ||
if (!process.env.ELECTRON_CHROMEDRIVER_STABLE_FALLBACK) { | ||
console.log('WARNING: chromedriver in development needs the environment variable ELECTRON_CHROMEDRIVER_STABLE_FALLBACK set') | ||
process.exit(1) | ||
} | ||
const fetch = require('node-fetch') | ||
const releases = await fetch('https://releases.electronjs.org/releases.json').then(response => response.json()) | ||
version = getLatestStable(releases).version | ||
} | ||
try { | ||
@@ -24,0 +63,0 @@ const targetFolder = path.join(__dirname, 'bin') |
{ | ||
"name": "electron-chromedriver", | ||
"version": "22.0.0", | ||
"version": "23.0.0", | ||
"description": "Electron ChromeDriver", | ||
@@ -24,5 +24,8 @@ "repository": "https://github.com/electron/chromedriver", | ||
"devDependencies": { | ||
"@continuous-auth/client": "^2.2.2", | ||
"mocha": "^10.1.0", | ||
"node-fetch": "^2.6.9", | ||
"semver": "^7.3.8", | ||
"standard": "^13.1.0" | ||
} | ||
} | ||
} |
# Electron ChromeDriver | ||
[](https://circleci.com/gh/electron/chromedriver/tree/main) | ||
[](https://ci.appveyor.com/project/electron-bot/chromedriver/branch/main) | ||
[](https://circleci.com/gh/electron/chromedriver/tree/main) | ||
[](https://www.npmjs.com/package/electron-chromedriver) | ||
<br> | ||
@@ -9,3 +9,2 @@ [](https://standardjs.com/) | ||
<br> | ||
[](https://www.npmjs.com/package/electron-chromedriver) | ||
[](https://www.npmjs.com/package/electron-chromedriver) | ||
@@ -12,0 +11,0 @@ |
@@ -13,4 +13,4 @@ const { promises: fs } = require('fs') | ||
if (!versionFormat.test(version)) { | ||
console.error(`Invalid version ${version}`) | ||
process.exit(1) | ||
console.error(`Unsupported version ${version} - only major, minor, and patch releases are currently supported`) | ||
return | ||
} | ||
@@ -17,0 +17,0 @@ |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Network access
Supply chain riskThis module accesses the network.
Found 1 instance in 1 package
New author
Supply chain riskA new npm collaborator published a version of the package for the first time. New collaborators are usually benign additions to a project, but do indicate a change to the security surface area of a package.
Found 1 instance in 1 package
Environment variable access
Supply chain riskPackage accesses environment variables, which may be a sign of credential stuffing or data theft.
Found 1 instance in 1 package
AI-detected potential code anomaly
Supply chain riskAI has identified unusual behaviors that may pose a security risk.
Found 1 instance in 1 package
New author
Supply chain riskA new npm collaborator published a version of the package for the first time. New collaborators are usually benign additions to a project, but do indicate a change to the security surface area of a package.
Found 1 instance in 1 package
14877
50.24%11
22.22%135
46.74%5
150%44
-2.22%15
15.38%4
100%