Merge pull request #14 from JakeGuy11/master

Fix handling for non-existent or empty config files
This commit is contained in:
Izuco 2021-07-06 18:28:48 +02:00 committed by GitHub
commit d824fd15af
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

24
funi.js
View file

@ -37,6 +37,24 @@ let cfg = {
cli: getYamlCfg(cliCfgFile),
};
// make sure cfg params aren't null
if (cfg.bin === null){
cfg.bin = {};
console.log('[WARN] bin-path.yml is empty or does not exist!\n');
}
if (cfg.dir === null){
cfg.dir = {};
console.log('[WARN] dir-path.yml is empty or does not exist!\n');
}
if (!Object.prototype.hasOwnProperty.call(cfg.dir, 'content')) cfg.dir.content = './videos/';
if (cfg.cli === null){
cfg.cli = {};
console.log('[WARN] cli-defaults.yml is empty or does not exist!\n');
}
/* Normalise paths for use outside the current directory */
for (let key of Object.keys(cfg.dir)) {
if (!path.isAbsolute(cfg.dir[key])) {
@ -52,7 +70,9 @@ for (let key of Object.keys(cfg.bin)) {
// token
let token = getYamlCfg(tokenFile);
token = token.token ? token.token : false;
if (token === null) token = false;
else if (token.token === null) token = false;
else token = token.token;
// info if token not set
if(!token){
@ -891,4 +911,4 @@ function parseFileName(input, title, episode, showTitle, season, width, height)
}
}
return shlp.cleanupFilename(input);
}
}