Skip to content

Commit

Permalink
Refactor supportedChains initialization in utils.js
Browse files Browse the repository at this point in the history
  • Loading branch information
yerofey committed Feb 2, 2024
1 parent 722f76a commit ec97c5b
Showing 1 changed file with 11 additions and 3 deletions.
14 changes: 11 additions & 3 deletions src/utils.js
Original file line number Diff line number Diff line change
Expand Up @@ -37,8 +37,16 @@ const objectHasAllKeys = (obj, keysArray) =>

let supportedChains = [];
const chainsFolder = path.join(dirname(import.meta.url), 'chains');
supportedChains = filesList(chainsFolder).map((item) =>
item.replace(chainsFolder, '').replace('.json', '').replace('/', '')
);
supportedChains = filesList(chainsFolder).map((item) => {
// Normalize path separators to the current OS's default
const normalizedItemPath = item.split(path.sep).join(path.posix.sep);
// Remove the chains folder path and the .json extension
return normalizedItemPath
.replace(
chainsFolder.split(path.sep).join(path.posix.sep) + path.posix.sep,
''
)
.replace('.json', '');
});

export { log, loadFile, loadJson, objectHasAllKeys, supportedChains };

0 comments on commit ec97c5b

Please sign in to comment.