@lando/backdrop
Version:
A Lando plugin that provides a tight integration with Backdrop.
40 lines (33 loc) • 1.08 kB
JavaScript
;
// Modules
const _ = require('lodash');
const fs = require('fs');
/*
* Helper to get database type
*/
const getDatabaseType = options => {
return _.get(options, '_app.config.services.database.type', options.database) ?? 'mysql';
};
module.exports = options => {
// Get the viaconf
if (_.startsWith(options.via, 'nginx')) options.defaultFiles.vhosts = 'default.conf.tpl';
// Get the default db conf
const dbConfig = getDatabaseType(options);
const database = _.first(dbConfig.split(':'));
const version = _.last(dbConfig.split(':')).substring(0, 2);
if (database === 'backdrop-mysql' || database === 'mysql' || database === 'mariadb') {
if (version === '8.') {
options.defaultFiles.database = 'mysql8.cnf';
} else {
options.defaultFiles.database = 'mysql.cnf';
}
}
// Verify files exist and remove if it doesn't
_.forEach(options.defaultFiles, (file, type) => {
if (!fs.existsSync(`${options.confDest}/${file}`)) {
delete options.defaultFiles[type];
}
});
// Return
return options.defaultFiles;
};