Skip to content

[JS]: Handle optional dependency for @bazel/runfiles #14352

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 7 commits into from
Aug 10, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 12 additions & 1 deletion javascript/node/selenium-webdriver/testing/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,6 @@
const fs = require('node:fs')
const path = require('node:path')
const { isatty } = require('node:tty')
const { runfiles } = require('@bazel/runfiles')
const chrome = require('../chrome')
const edge = require('../edge')
const firefox = require('../firefox')
Expand All @@ -46,6 +45,14 @@ const { Browser } = require('../lib/capabilities')
const { Builder } = require('../index')
const { getBinaryPaths } = require('../common/driverFinder')

let runfiles
try {
// Attempt to require @bazel/runfiles
runfiles = require('@bazel/runfiles').runfiles
} catch {
// Fall through
}

/**
* Describes a browser targeted by a {@linkplain suite test suite}.
* @record
Expand Down Expand Up @@ -544,6 +551,10 @@ function locate(fileLike) {
return fileLike
}

if (!runfiles) {
throw new Error('Unable to find ' + fileLike)
}

try {
return runfiles.resolve(fileLike)
} catch {
Expand Down
Loading