mirror of
https://github.com/TryGhost/Ghost.git
synced 2025-03-11 02:12:21 -05:00
Refactored model init to be implicit
- no more need to explictly add a model file to be loaded! - this makes building Ghost just the tiniest smidge easier
This commit is contained in:
parent
99fde5154f
commit
2777093c76
1 changed files with 4 additions and 44 deletions
|
@ -3,6 +3,7 @@
|
|||
*/
|
||||
|
||||
const _ = require('lodash');
|
||||
const glob = require('glob');
|
||||
|
||||
// enable event listeners
|
||||
require('./base/listeners');
|
||||
|
@ -12,53 +13,12 @@ require('./base/listeners');
|
|||
*/
|
||||
exports = module.exports;
|
||||
|
||||
const models = [
|
||||
'action',
|
||||
'permission',
|
||||
'post',
|
||||
'role',
|
||||
'settings',
|
||||
'custom-theme-setting',
|
||||
'session',
|
||||
'tag',
|
||||
'tag-public',
|
||||
'user',
|
||||
'author',
|
||||
'invite',
|
||||
'webhook',
|
||||
'integration',
|
||||
'api-key',
|
||||
'mobiledoc-revision',
|
||||
'member',
|
||||
'offer',
|
||||
'offer-redemption',
|
||||
'product',
|
||||
'benefit',
|
||||
'stripe-product',
|
||||
'stripe-price',
|
||||
'member-subscribe-event',
|
||||
'member-paid-subscription-event',
|
||||
'member-login-event',
|
||||
'member-email-change-event',
|
||||
'member-payment-event',
|
||||
'member-status-event',
|
||||
'member-product-event',
|
||||
'member-analytic-event',
|
||||
'posts-meta',
|
||||
'member-stripe-customer',
|
||||
'stripe-customer-subscription',
|
||||
'email',
|
||||
'email-batch',
|
||||
'email-recipient',
|
||||
'label',
|
||||
'single-use-token',
|
||||
'snippet'
|
||||
];
|
||||
|
||||
function init() {
|
||||
exports.Base = require('./base');
|
||||
|
||||
models.forEach(function (name) {
|
||||
let modelsFiles = glob.sync('!(index).js', {cwd: __dirname});
|
||||
modelsFiles.forEach((model) => {
|
||||
const name = model.replace(/.js$/, '');
|
||||
_.extend(exports, require('./' + name));
|
||||
});
|
||||
}
|
||||
|
|
Loading…
Add table
Reference in a new issue