mirror of
https://github.com/digitalocean/nginxconfig.io.git
synced 2025-11-05 18:56:09 +08:00
Do some cleanup
This commit is contained in:
@@ -1,22 +1,13 @@
|
||||
import toConf from './to_conf';
|
||||
import nginxConf from './nginx.conf';
|
||||
|
||||
const toConfig = obj => {
|
||||
// Convert the obj to nginx
|
||||
const rawConf = toConf(obj);
|
||||
|
||||
// Do some magic to comments
|
||||
const commentConf = rawConf
|
||||
.replace(/^([^\S\r\n]*[^#\s].*[^\n])\n([^\S\r\n]*)#/gm, '$1\n\n$2#') // Double linebreak before comment
|
||||
.replace(/^([^\S\r\n]*#.*\n[^\S\r\n]*#.*\n)([^\S\r\n]*[^#\s])/gm, '$1\n$2') // Double linebreak after double comment
|
||||
|
||||
return commentConf;
|
||||
}
|
||||
// Convert the data to nginx conf and do some magic to comments
|
||||
const toConfig = entriesOrObject => toConf(entriesOrObject)
|
||||
.replace(/^([^\S\r\n]*[^#\s].*[^\n])\n([^\S\r\n]*)#/gm, '$1\n\n$2#') // Double linebreak before comment
|
||||
.replace(/^([^\S\r\n]*#.*\n[^\S\r\n]*#.*\n)([^\S\r\n]*[^#\s])/gm, '$1\n$2'); // Double linebreak after double comment
|
||||
|
||||
export default (domains, global) => {
|
||||
const files = {};
|
||||
|
||||
files['nginx.conf'] = toConfig(nginxConf(domains, global));
|
||||
|
||||
const files = [];
|
||||
files.push(['nginx.conf', toConfig(nginxConf(domains, global))]);
|
||||
return files;
|
||||
}
|
||||
};
|
||||
|
||||
@@ -46,6 +46,6 @@ const recurse = (entriesOrObject, depth) => {
|
||||
}
|
||||
|
||||
return retVal.replace(/\n\n\n/g, '\n\n');
|
||||
}
|
||||
};
|
||||
|
||||
export default entriesOrObject => recurse(entriesOrObject, 0);
|
||||
|
||||
Reference in New Issue
Block a user