Skip to content

Commit

Permalink
#1270: fox Prototype-polluting assignment warning
Browse files Browse the repository at this point in the history
  • Loading branch information
JoernBerkefeld committed Jun 6, 2024
1 parent 40899c7 commit d02f08e
Show file tree
Hide file tree
Showing 5 changed files with 38 additions and 2 deletions.
2 changes: 1 addition & 1 deletion @types/lib/index.d.ts.map

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

9 changes: 9 additions & 0 deletions @types/lib/util/util.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -83,6 +83,15 @@ export namespace Util {
* @returns {boolean} type ok or not
*/
function _isValidType(selectedType: string, handleOutside?: boolean): boolean;
/**
* helper for Mcdev.retrieve, Mcdev.retrieveAsTemplate and Mcdev.deploy
*
* @param {Mcdevrc} properties javascript object in .mcdevrc.json
* @param {string} businessUnit name of BU
* @param {boolean} [handleOutside] if the API reponse is irregular this allows you to handle it outside of this generic method
* @returns {boolean} bu found or not
*/
function _isValidBU(properties: import("../../types/mcdev.d.js").Mcdevrc, businessUnit: string, handleOutside?: boolean): boolean;
/**
* helper that deals with extracting type and subtype
*
Expand Down
2 changes: 1 addition & 1 deletion @types/lib/util/util.d.ts.map

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 3 additions & 0 deletions lib/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -1047,6 +1047,9 @@ class Mcdev {
this.setOptions({ referenceFrom, referenceTo });

const properties = await config.getProperties();
if (!Util._isValidBU(properties, businessUnit)) {
return;
}
if (selectedTypesArr) {
// check if types are valid
for (const selectedType of Object.keys(selectedTypesArr)) {
Expand Down
24 changes: 24 additions & 0 deletions lib/util/util.js
Original file line number Diff line number Diff line change
Expand Up @@ -213,6 +213,30 @@ export const Util = {
return true;
},

/**
* helper for Mcdev.retrieve, Mcdev.retrieveAsTemplate and Mcdev.deploy
*
* @param {Mcdevrc} properties javascript object in .mcdevrc.json
* @param {string} businessUnit name of BU
* @param {boolean} [handleOutside] if the API reponse is irregular this allows you to handle it outside of this generic method
* @returns {boolean} bu found or not
*/
_isValidBU(properties, businessUnit, handleOutside) {
const [cred, bu] = businessUnit ? businessUnit.split('/') : [null, null];
if (!properties.credentials[cred]) {
if (!handleOutside) {
Util.logger.error(`Credential not found`);
}
return false;
} else if (!properties.credentials[cred].businessUnits[bu]) {
if (!handleOutside) {
Util.logger.error(`BU not found in credential`);
}
return false;
}
return true;
},

/**
* helper that deals with extracting type and subtype
*
Expand Down

0 comments on commit d02f08e

Please sign in to comment.