Added UMD support

This commit is contained in:
Matthew Wilkes 2016-08-09 14:08:04 +01:00
parent 13a049412a
commit 076ab08f58
1 changed files with 15 additions and 0 deletions

View File

@ -248,6 +248,12 @@ function defineModels(app, instructions) {
if (typeof code === 'function') {
debug('Customizing model %s', name);
code(model);
// If code is a default UMD module use it
} else if (code.hasOwnProperty('default')) {
if (typeof code.default === 'function') {
debug('Customizing model %s', name);
code.default(model);
}
} else {
debug('Skipping model file %s - `module.exports` is not a function',
data.sourceFile);
@ -295,6 +301,15 @@ function runScripts(app, list, callback) {
path: filepath,
func: exports,
});
// If the file contains a default UMD module, load it
} else if (exports.hasOwnProperty('default')) {
if (typeof exports.default === 'function') {
debug('Exported function detected %s', filepath);
functions.push({
path: filepath,
func: exports.default,
});
}
}
} catch (err) {
g.error('Failed loading boot script: %s\n%s', filepath, err.stack);