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}
|
* @returns {SafeChainConfig}
|
||||||
*/
|
*/
|
||||||
|
|
@ -167,26 +176,14 @@ function readConfigFile() {
|
||||||
const configFilePath = getConfigFilePath();
|
const configFilePath = getConfigFilePath();
|
||||||
|
|
||||||
if (!fs.existsSync(configFilePath)) {
|
if (!fs.existsSync(configFilePath)) {
|
||||||
return {
|
return emptyConfig;
|
||||||
scanTimeout: undefined,
|
|
||||||
minimumPackageAgeHours: undefined,
|
|
||||||
npm: {
|
|
||||||
customRegistries: undefined,
|
|
||||||
},
|
|
||||||
};
|
|
||||||
}
|
}
|
||||||
|
|
||||||
try {
|
try {
|
||||||
const data = fs.readFileSync(configFilePath, "utf8");
|
const data = fs.readFileSync(configFilePath, "utf8");
|
||||||
return JSON.parse(data);
|
return JSON.parse(data);
|
||||||
} catch {
|
} catch {
|
||||||
return {
|
return emptyConfig;
|
||||||
scanTimeout: undefined,
|
|
||||||
minimumPackageAgeHours: undefined,
|
|
||||||
npm: {
|
|
||||||
customRegistries: undefined,
|
|
||||||
},
|
|
||||||
};
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue