mirror of
https://github.com/AikidoSec/safe-chain.git
synced 2026-05-26 12:10:49 +00:00
Create a single emptyConfig object
This commit is contained in:
parent
e3aa2e15cb
commit
deb0ad5428
1 changed files with 11 additions and 14 deletions
|
|
@ -160,6 +160,15 @@ export function readDatabaseFromLocalCache() {
|
|||
}
|
||||
}
|
||||
|
||||
/** @type {SafeChainConfig} */
|
||||
const emptyConfig = {
|
||||
scanTimeout: undefined,
|
||||
minimumPackageAgeHours: undefined,
|
||||
npm: {
|
||||
customRegistries: undefined,
|
||||
},
|
||||
};
|
||||
|
||||
/**
|
||||
* @returns {SafeChainConfig}
|
||||
*/
|
||||
|
|
@ -167,26 +176,14 @@ function readConfigFile() {
|
|||
const configFilePath = getConfigFilePath();
|
||||
|
||||
if (!fs.existsSync(configFilePath)) {
|
||||
return {
|
||||
scanTimeout: undefined,
|
||||
minimumPackageAgeHours: undefined,
|
||||
npm: {
|
||||
customRegistries: undefined,
|
||||
},
|
||||
};
|
||||
return emptyConfig;
|
||||
}
|
||||
|
||||
try {
|
||||
const data = fs.readFileSync(configFilePath, "utf8");
|
||||
return JSON.parse(data);
|
||||
} catch {
|
||||
return {
|
||||
scanTimeout: undefined,
|
||||
minimumPackageAgeHours: undefined,
|
||||
npm: {
|
||||
customRegistries: undefined,
|
||||
},
|
||||
};
|
||||
return emptyConfig;
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue