Skip to content

Commit

Permalink
fix: options overrides ci
Browse files Browse the repository at this point in the history
  • Loading branch information
gregberge committed Jan 4, 2023
1 parent 760abb1 commit 047d865
Showing 1 changed file with 26 additions and 30 deletions.
56 changes: 26 additions & 30 deletions packages/core/src/upload.ts
Original file line number Diff line number Diff line change
Expand Up @@ -39,42 +39,38 @@ export interface UploadParameters {
}

const getConfigFromOptions = (options: UploadParameters) => {
const { apiBaseUrl, commit, branch, token, buildName, parallel, prNumber } =
options;

const config = createConfig();

const ciEnv = getCiEnvironment();
if (ciEnv) {
config.load(
omitUndefined({
commit: ciEnv.commit,
branch: ciEnv.branch,
ciService: ciEnv.name,
owner: ciEnv.owner,
repository: ciEnv.repository,
jobId: ciEnv.jobId,
runId: ciEnv.runId,
prNumber: ciEnv.prNumber,
})
);
}

config.load(
omitUndefined({
apiBaseUrl,
commit,
branch,
token,
prNumber,
buildName,
parallel: Boolean(parallel),
parallelNonce: parallel ? parallel.nonce : null,
parallelTotal: parallel ? parallel.total : null,
apiBaseUrl: options.apiBaseUrl,
commit: options.commit,
branch: options.branch,
token: options.token,
prNumber: options.prNumber,
buildName: options.buildName,
parallel: Boolean(options.parallel),
parallelNonce: options.parallel ? options.parallel.nonce : null,
parallelTotal: options.parallel ? options.parallel.total : null,
})
);

if (!config.get("commit")) {
const ciEnv = getCiEnvironment();
if (ciEnv) {
config.load(
omitUndefined({
commit: ciEnv.commit,
branch: ciEnv.branch,
ciService: ciEnv.name,
owner: ciEnv.owner,
repository: ciEnv.repository,
jobId: ciEnv.jobId,
runId: ciEnv.runId,
prNumber: ciEnv.prNumber,
})
);
}
}

config.validate();

return config.get();
Expand Down

0 comments on commit 047d865

Please sign in to comment.