mirror of
https://github.com/strapi/strapi.git
synced 2025-12-27 07:03:38 +00:00
Expose globals
This commit is contained in:
parent
185542b74f
commit
3cd111bdb2
@ -50,8 +50,8 @@ module.exports = class Strapi extends EventEmitter {
|
||||
}
|
||||
|
||||
// Private method to expose instance globals
|
||||
this.exposeGlobals = () => {
|
||||
require('./private/exposeGlobals').apply(this);
|
||||
this.exposeGlobals = cb => {
|
||||
require('./private/exposeGlobals').apply(this, [cb]);
|
||||
}
|
||||
|
||||
// Private method to run instance bootstrap
|
||||
|
||||
@ -44,17 +44,16 @@ module.exports = strapi => {
|
||||
configOverride = configOverride || {};
|
||||
strapi.config = _.cloneDeep(configOverride);
|
||||
|
||||
// Optionally expose globals as soon as the
|
||||
// config hook is loaded.
|
||||
strapi.on('hook:_config:loaded', strapi.exposeGlobals);
|
||||
|
||||
async.auto({
|
||||
// Apply core defaults and hook-agnostic configuration,
|
||||
// esp. overrides including command-line options, environment variables,
|
||||
// and options that were passed in programmatically.
|
||||
config: [Configuration.load],
|
||||
// Optionally expose globals as soon as the
|
||||
// config hook is loaded.
|
||||
exposeGlobals: ['config', strapi.exposeGlobals],
|
||||
// Initiliaze hooks global variable and configurations
|
||||
hooks: ['config', initializeHooks],
|
||||
hooks: ['exposeGlobals', initializeHooks],
|
||||
// Load core's hooks into memory, with their middleware and routes.
|
||||
dictionary: ['hooks', cb => loader('dictionary', cb)],
|
||||
// Load core's hooks into memory, with their middleware and routes.
|
||||
|
||||
@ -8,11 +8,10 @@
|
||||
* @api private
|
||||
*/
|
||||
|
||||
module.exports = function exposeGlobals() {
|
||||
module.exports = cb => {
|
||||
global.async = require('async');
|
||||
global._ = require('lodash');
|
||||
|
||||
console.log(this);
|
||||
|
||||
global.strapi = this;
|
||||
|
||||
return cb();
|
||||
};
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user