mirror of
https://github.com/strapi/strapi.git
synced 2025-07-23 09:00:19 +00:00
38 lines
739 B
JavaScript
38 lines
739 B
JavaScript
![]() |
'use strict';
|
||
|
|
||
|
/**
|
||
|
* `exposeGlobals()`
|
||
|
*
|
||
|
* Expose certain global variables
|
||
|
* (if config says so).
|
||
|
*
|
||
|
* @api private
|
||
|
*/
|
||
|
|
||
|
module.exports = function exposeGlobals() {
|
||
|
const self = this;
|
||
|
|
||
|
// Globals explicitly disabled.
|
||
|
if (self.config.globals === false) {
|
||
|
return;
|
||
|
}
|
||
|
|
||
|
// Expose globals as an empty object.
|
||
|
self.config.globals = self.config.globals || {};
|
||
|
|
||
|
// Expose Async globally if enabled.
|
||
|
if (self.config.globals.async !== false) {
|
||
|
global.async = require('async');
|
||
|
}
|
||
|
|
||
|
// Expose Lodash globally if enabled.
|
||
|
if (self.config.globals._ !== false) {
|
||
|
global._ = require('lodash');
|
||
|
}
|
||
|
|
||
|
// Expose Strapi globally if enabled.
|
||
|
if (self.config.globals.strapi !== false) {
|
||
|
global.strapi = self;
|
||
|
}
|
||
|
};
|