Skip to content

Commit 8b9d680

Browse files
Straighten the method with guard clauses
1 parent bd6a15a commit 8b9d680

File tree

1 file changed

+7
-12
lines changed

1 file changed

+7
-12
lines changed

lib/commons/config.js

Lines changed: 7 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -18,18 +18,13 @@ const getRequiredOption = (options, optionName) => {
1818
};
1919

2020
const getApiKey = ({ apiKey, token }) => {
21-
let calculatedApiKey = apiKey;
22-
if (!calculatedApiKey) {
23-
calculatedApiKey = token;
24-
if (!calculatedApiKey) {
25-
throw new ReportPortalRequiredOptionError('apiKey');
26-
} else {
27-
console.warn(`Option 'token' is deprecated. Use 'apiKey' instead.`);
28-
}
29-
}
30-
31-
return calculatedApiKey;
32-
};
21+
if (apiKey) return apiKey;
22+
23+
if (!token) throw new ReportPortalRequiredOptionError('apiKey');
24+
25+
console.warn(`Option 'token' is deprecated. Use 'apiKey' instead.`);
26+
return token;
27+
}
3328

3429
const getClientConfig = (options) => {
3530
let calculatedOptions = options;

0 commit comments

Comments
 (0)