Skip to content

Commit

Permalink
always extend metadata with runner when starting sauce connect
Browse files Browse the repository at this point in the history
  • Loading branch information
budziam committed Jan 29, 2025
1 parent 04817a3 commit 015c8a8
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 0 deletions.
1 change: 1 addition & 0 deletions src/constants.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import os from 'os';
import {version} from '../package.json';

export const DEFAULT_SAUCE_CONNECT_VERSION = '5.2.2';
export const DEFAULT_RUNNER_NAME = 'node-saucelabs';
export const SAUCE_VERSION_NOTE = `node-saucelabs v${version}\nSauce Connect v${DEFAULT_SAUCE_CONNECT_VERSION}`;

const protocols = [
Expand Down
11 changes: 11 additions & 0 deletions src/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@ import {
DEFAULT_SAUCE_CONNECT_VERSION,
SC_FAILURE_MESSAGES,
SC_BOOLEAN_CLI_PARAMS,
DEFAULT_RUNNER_NAME,
} from './constants';
import SauceConnectLoader from './sauceConnectLoader';

Expand Down Expand Up @@ -248,6 +249,16 @@ export default class SauceLabs {
);
}

// Provide a default runner name. It's used for identifying the tunnel's initiation method.
if (!argv['metadata']) {
argv = {...argv, metadata: `runner=${DEFAULT_RUNNER_NAME}`};
} else if (!argv['metadata'].includes('runner=')) {
argv = {
...argv,
metadata: `runner=${DEFAULT_RUNNER_NAME},${argv['metadata']}`,
};
}

const scUpstreamProxy = argv.scUpstreamProxy;
const args = Object.entries(argv)
/**
Expand Down
1 change: 1 addition & 0 deletions tests/__snapshots__/index.test.js.snap
Original file line number Diff line number Diff line change
Expand Up @@ -162,6 +162,7 @@ exports[`startSauceConnect should start sauce connect with proper parsed args 1`
"run",
"--proxy-tunnel=abc",
"--verbose=true",
"--metadata=runner=node-saucelabs",
"--username=foo",
"--access-key=bar",
"--region=eu-central-1",
Expand Down

0 comments on commit 015c8a8

Please sign in to comment.