Settings.js: trivial reformatting

This commit is contained in:
muxator 2019-03-10 01:46:55 +01:00 committed by muxator
parent ee4a27d10e
commit d526c5ccca

View file

@ -287,12 +287,9 @@ exports.scrollWhenFocusLineIsOutOfViewport = {
//checks if abiword is avaiable //checks if abiword is avaiable
exports.abiwordAvailable = function() exports.abiwordAvailable = function()
{ {
if(exports.abiword != null) if (exports.abiword != null) {
{
return os.type().indexOf("Windows") != -1 ? "withoutPDF" : "yes"; return os.type().indexOf("Windows") != -1 ? "withoutPDF" : "yes";
} } else {
else
{
return "no"; return "no";
} }
}; };
@ -321,8 +318,7 @@ exports.exportAvailable = function () {
// Provide git version if available // Provide git version if available
exports.getGitCommit = function() { exports.getGitCommit = function() {
var version = ""; var version = "";
try try {
{
var rootPath = path.resolve(npm.dir, '..'); var rootPath = path.resolve(npm.dir, '..');
if (fs.lstatSync(rootPath + '/.git').isFile()) { if (fs.lstatSync(rootPath + '/.git').isFile()) {
rootPath = fs.readFileSync(rootPath + '/.git', "utf8"); rootPath = fs.readFileSync(rootPath + '/.git', "utf8");
@ -334,9 +330,7 @@ exports.getGitCommit = function() {
var refPath = rootPath + "/" + ref.substring(5, ref.indexOf("\n")); var refPath = rootPath + "/" + ref.substring(5, ref.indexOf("\n"));
version = fs.readFileSync(refPath, "utf-8"); version = fs.readFileSync(refPath, "utf-8");
version = version.substring(0, 7); version = version.substring(0, 7);
} } catch(e) {
catch(e)
{
console.warn("Can't get git version for server header\n" + e.message) console.warn("Can't get git version for server header\n" + e.message)
} }
return version; return version;
@ -391,53 +385,43 @@ exports.reloadSettings = function reloadSettings() {
} }
//loop trough the settings //loop trough the settings
for(var i in settings) for (var i in settings) {
{
//test if the setting start with a lowercase character //test if the setting start with a lowercase character
if(i.charAt(0).search("[a-z]") !== 0) if (i.charAt(0).search("[a-z]") !== 0) {
{
console.warn(`Settings should start with a lowercase character: '${i}'`); console.warn(`Settings should start with a lowercase character: '${i}'`);
} }
//we know this setting, so we overwrite it //we know this setting, so we overwrite it
//or it's a settings hash, specific to a plugin //or it's a settings hash, specific to a plugin
if(exports[i] !== undefined || i.indexOf('ep_')==0) if (exports[i] !== undefined || i.indexOf('ep_') == 0) {
{
if (_.isObject(settings[i]) && !_.isArray(settings[i])) { if (_.isObject(settings[i]) && !_.isArray(settings[i])) {
exports[i] = _.defaults(settings[i], exports[i]); exports[i] = _.defaults(settings[i], exports[i]);
} else { } else {
exports[i] = settings[i]; exports[i] = settings[i];
} }
} } else {
//this setting is unkown, output a warning and throw it away // this setting is unknown, output a warning and throw it away
else
{
console.warn(`Unknown Setting: '${i}'. This setting doesn't exist or it was removed`); console.warn(`Unknown Setting: '${i}'. This setting doesn't exist or it was removed`);
} }
} }
//loop trough the settings //loop trough the settings
for(var i in credentials) for (var i in credentials) {
{
//test if the setting start with a lowercase character //test if the setting start with a lowercase character
if(i.charAt(0).search("[a-z]") !== 0) if (i.charAt(0).search("[a-z]") !== 0) {
{
console.warn(`Settings should start with a lowercase character: '${i}'`); console.warn(`Settings should start with a lowercase character: '${i}'`);
} }
//we know this setting, so we overwrite it //we know this setting, so we overwrite it
//or it's a settings hash, specific to a plugin //or it's a settings hash, specific to a plugin
if(exports[i] !== undefined || i.indexOf('ep_')==0) if (exports[i] !== undefined || i.indexOf('ep_') == 0) {
{
if (_.isObject(credentials[i]) && !_.isArray(credentials[i])) { if (_.isObject(credentials[i]) && !_.isArray(credentials[i])) {
exports[i] = _.defaults(credentials[i], exports[i]); exports[i] = _.defaults(credentials[i], exports[i]);
} else { } else {
exports[i] = credentials[i]; exports[i] = credentials[i];
} }
} } else {
//this setting is unkown, output a warning and throw it away // this setting is unknown, output a warning and throw it away
else
{
console.warn(`Unknown Setting: '${i}'. This setting doesn't exist or it was removed`); console.warn(`Unknown Setting: '${i}'. This setting doesn't exist or it was removed`);
} }
} }
@ -485,8 +469,7 @@ exports.reloadSettings = function reloadSettings() {
if (exports.abiword) { if (exports.abiword) {
// Check abiword actually exists // Check abiword actually exists
if(exports.abiword != null) if (exports.abiword != null) {
{
fs.exists(exports.abiword, function(exists) { fs.exists(exports.abiword, function(exists) {
if (!exists) { if (!exists) {
var abiwordError = "Abiword does not exist at this path, check your settings file"; var abiwordError = "Abiword does not exist at this path, check your settings file";