Skip to content

Commit

Permalink
Merge pull request #49 from sgarner/fix-no-package-file
Browse files Browse the repository at this point in the history
Fix infinite loop when no package config found
  • Loading branch information
runk authored Mar 17, 2024
2 parents 462c84b + 7372f74 commit 7781fbe
Showing 1 changed file with 7 additions and 4 deletions.
11 changes: 7 additions & 4 deletions utils.js
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,9 @@ const getConfigWithDir = () => {
if (config) return { config, dir };
}

dir = path.join(dir, '..');
const parentDir = path.resolve(dir, '..');
if (parentDir === dir) break;
dir = parentDir;
}

console.log(
Expand Down Expand Up @@ -56,10 +58,11 @@ const getLicense = () => {
};

const getSelectedDbs = () => {
const config = getConfig();
const selected = config['selected-dbs'];
const valids = ['City', 'Country', 'ASN'];
if (!selected) return valids;

const config = getConfig();
const selected = config?.['selected-dbs'] ?? valids;

if (!Array.isArray(selected)) {
console.error('selected-dbs property must have be an array.');
process.exit(1);
Expand Down

0 comments on commit 7781fbe

Please sign in to comment.