Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
defaultEnvParams(
process.env.HOST || nconf.get('service:host'),
process.env.PORT || nconf.get('service:port'),
'service'
);
defaultEnvParams(
process.env.REDIS_HOST || nconf.get('redis:host'),
process.env.REDIS_PORT || nconf.get('redis:port'),
'redis'
);
// allow a redis://user:host:port url, takes precedence
if (process.env.REDIS_URL) {
nconf.set('redis:url', process.env.REDIS_URL);
nconf.clear('redis:host');
nconf.clear('redis:port');
}
}
get = (key: string): any => nconf.get(key);
// show all
if (argv.key.length === 0)
return log.info(prettyConfig(loadConfig(argv.all)));
// sugar: notice user that use ':' instead of '.'
if (argv.key.includes('.') && !argv.key.includes(':'))
return log.printf('Key should use colon(:) as the delimiter, do you mean %s?',
chalk.yellow(argv.key.replace(/\./g, ':')));
const v = nconf.get(argv.key);
// delete
if (argv.delete) {
if (v === undefined) return log.fatal('Key not found: ' + argv.key);
nconf.clear(argv.key);
return saveConfig();
}
// show
if (argv.value.length === 0) {
if (v === undefined) return log.fatal('Key not found: ' + argv.key);
return log.info(prettyConfig(v));
}
// set
try {
nconf.set(argv.key, JSON.parse(argv.value));
} catch (e) {
nconf.set(argv.key, JSON.parse('"' + argv.value + '"'));
}
return saveConfig();
function _config (key, value) {
if (key && value !== null) {
if (value === '') {
program.log.debug('Clearing key', key);
nconf.clear(key);
} else {
program.log.debug('Setting key', key, 'to', value);
nconf.set(key, value);
}
nconf.save();
console.log(nconf.save());
} else if (key) {
program.log.debug('Retrieving key', key);
console.log(nconf.get(key));
} else {
program.log.debug('Listing all kay-values');
console.log(nconf.load());
}
}
destinationDir : 'Shows',
digitalAudioPreference : Preference.preferred,
hdVideoPreference : Preference.preferred
},
musicSettings : {
maxSize : 300,
destinationDir : 'Music',
losslessFormatPreference : Preference.optional
},
});
var legacyHdVideoPreference1 = nconf.get('movieSettings:requireHD');
if (legacyHdVideoPreference1) {
nconf.set('movieSettings:hdVideoPreference', legacyHdVideoPreference1);
nconf.clear('movieSettings:requireHD');
}
var legacyHdVideoPreference2 = nconf.get('showSettings:requireHD');
if (legacyHdVideoPreference2) {
nconf.set('showSettings:hdVideoPreference', legacyHdVideoPreference2);
nconf.clear('showSettings:requireHD');
}
var legacyDigitalAudioPreference1 = nconf.get('movieSettings:requireDigitalSound');
if (legacyDigitalAudioPreference1) {
nconf.set('movieSettings:digitalAudioPreference', legacyDigitalAudioPreference1);
nconf.clear('movieSettings:requireDigitalSound');
}
nconf.set('showSettings:hdVideoPreference', legacyHdVideoPreference2);
nconf.clear('showSettings:requireHD');
}
var legacyDigitalAudioPreference1 = nconf.get('movieSettings:requireDigitalSound');
if (legacyDigitalAudioPreference1) {
nconf.set('movieSettings:digitalAudioPreference', legacyDigitalAudioPreference1);
nconf.clear('movieSettings:requireDigitalSound');
}
var legacyDigitalAudioPreference2 = nconf.get('showSettings:requireDigitalSound');
if (legacyDigitalAudioPreference2) {
nconf.set('showSettings:digitalAudioPreference', legacyDigitalAudioPreference2);
nconf.clear('showSettings:requireDigitalSound');
}
var legacyLosslessFormatPreference = nconf.get('musicSettings:requireLossless');
if (legacyLosslessFormatPreference) {
nconf.set('musicSettings:losslessFormatPreference', legacyLosslessFormatPreference);
nconf.clear('musicSettings:requireLossless');
}
if (legacyHdVideoPreference1 || legacyHdVideoPreference2 || legacyDigitalAudioPreference1 || legacyDigitalAudioPreference2 || legacyLosslessFormatPreference) {
nconf.save();
}
labels.add({
checkInterval : 'Check Interval [sec]',
movieSettings : '<span class="fa fa-film"> Movies',</span>
clear: function (key: string) {
nconf.clear(key);
self.save();
},
};
function (cb) {
var password = nconf.get('LDAP_BIND_PASSWORD');
if (password) {
nconf.clear('LDAP_BIND_PASSWORD');
nconf.set('LDAP_BIND_CREDENTIALS', crypto.encrypt(password));
}
cb();
},
function (cb) {
nconf.set('showSettings:hdVideoPreference', legacyHdVideoPreference2);
nconf.clear('showSettings:requireHD');
}
var legacyDigitalAudioPreference1 = nconf.get('movieSettings:requireDigitalSound');
if (legacyDigitalAudioPreference1) {
nconf.set('movieSettings:digitalAudioPreference', legacyDigitalAudioPreference1);
nconf.clear('movieSettings:requireDigitalSound');
}
var legacyDigitalAudioPreference2 = nconf.get('showSettings:requireDigitalSound');
if (legacyDigitalAudioPreference2) {
nconf.set('showSettings:digitalAudioPreference', legacyDigitalAudioPreference2);
nconf.clear('showSettings:requireDigitalSound');
}
var legacyLosslessFormatPreference = nconf.get('musicSettings:requireLossless');
if (legacyLosslessFormatPreference) {
nconf.set('musicSettings:losslessFormatPreference', legacyLosslessFormatPreference);
nconf.clear('musicSettings:requireLossless');
}
if (legacyHdVideoPreference1 || legacyHdVideoPreference2 || legacyDigitalAudioPreference1 || legacyDigitalAudioPreference2 || legacyLosslessFormatPreference) {
nconf.save();
}
labels.add({
checkInterval : 'Check Interval [sec]',
movieSettings : '<span class="fa fa-film"> Movies',</span>
clear: function (key: string) {
nconf.clear(key);
self.save();
},
};
nconf.set('movieSettings:digitalAudioPreference', legacyDigitalAudioPreference1);
nconf.clear('movieSettings:requireDigitalSound');
}
var legacyDigitalAudioPreference2 = nconf.get('showSettings:requireDigitalSound');
if (legacyDigitalAudioPreference2) {
nconf.set('showSettings:digitalAudioPreference', legacyDigitalAudioPreference2);
nconf.clear('showSettings:requireDigitalSound');
}
var legacyLosslessFormatPreference = nconf.get('musicSettings:requireLossless');
if (legacyLosslessFormatPreference) {
nconf.set('musicSettings:losslessFormatPreference', legacyLosslessFormatPreference);
nconf.clear('musicSettings:requireLossless');
}
if (legacyHdVideoPreference1 || legacyHdVideoPreference2 || legacyDigitalAudioPreference1 || legacyDigitalAudioPreference2 || legacyLosslessFormatPreference) {
nconf.save();
}
labels.add({
checkInterval : 'Check Interval [sec]',
movieSettings : '<span class="fa fa-film"> Movies',
maxSize : 'Max Size [MB]',
digitalAudioPreference : 'Digital Audio',
hdVideoPreference : 'HD Video',
showSettings : '<span class="fa fa-tv"> Shows',
musicSettings : '<span class="fa fa-music"> Music',
losslessFormatPreference : 'Lossless Format',
removeFinishedDays : 'Remove Finished Items After ? Days <small><em>0 is never</em></small>',</span></span></span>