Don't use duplicated computed value for nginx dir, watch initial value

This commit is contained in:
MattIPv4
2020-06-11 15:03:52 +01:00
parent 16a860f5ca
commit e4f219a286
7 changed files with 30 additions and 33 deletions

View File

@@ -128,6 +128,7 @@ THE SOFTWARE.
const defaults = {
nginxConfigDirectory: {
default: '/etc/nginx/',
computed: '/etc/nginx', // We use a watcher to trim trailing slashes
enabled: true,
},
workerProcesses: {
@@ -170,6 +171,16 @@ THE SOFTWARE.
},
computed: computedFromDefaults(defaults, 'nginx'), // Getters & setters for the delegated data
watch: {
// Clean nginx directory of trailing slashes
'$props.data.nginxConfigDirectory': {
handler(data) {
// This might cause recursion, but seems not to
if (data.enabled)
if (data.computed.endsWith('/'))
data.computed = data.computed.replace(/\/+$/, '');
},
deep: true,
},
// Check worker processes selection is valid
'$props.data.workerProcesses': {
handler(data) {