@adonisjs/ignitor
Advanced tools
Comparing version 1.0.11 to 1.0.12
@@ -0,1 +1,16 @@ | ||
<a name="1.0.12"></a> | ||
## [1.0.12](https://github.com/adonisjs/adonis-ignitor/compare/v1.0.11...v1.0.12) (2017-10-03) | ||
### Bug Fixes | ||
* **ignitor:** allow preload file path to be absolute ([bb35c48](https://github.com/adonisjs/adonis-ignitor/commit/bb35c48)) | ||
### Features | ||
* **autoload:** register all autoload directories from package.json file ([39d9015](https://github.com/adonisjs/adonis-ignitor/commit/39d9015)) | ||
<a name="1.0.11"></a> | ||
@@ -2,0 +17,0 @@ ## [1.0.11](https://github.com/adonisjs/adonis-ignitor/compare/v1.0.10...v1.0.11) (2017-09-14) |
{ | ||
"name": "@adonisjs/ignitor", | ||
"version": "1.0.11", | ||
"version": "1.0.12", | ||
"description": "Fire the adonis-app (in good sense)", | ||
@@ -5,0 +5,0 @@ "main": "index.js", |
@@ -134,15 +134,16 @@ 'use strict' | ||
/** | ||
* Sets up resolver by registering paths to important | ||
* directories and setting up the autoloaded path | ||
* to the IoC container. | ||
* Sets up resolver primary namespace and register paths to | ||
* important directories. | ||
* | ||
* @method _setupResolver | ||
* | ||
* @param {String} namespace | ||
* | ||
* @return {void} | ||
* | ||
* @private | ||
*/ | ||
_setupResolver () { | ||
const autoload = this._packageFile.autoload || {} | ||
let [ namespace ] = Object.keys(autoload) | ||
this.appNamespace = namespace || 'App' | ||
const autoloadDirectory = (path.join(this._appRoot, autoload[this.appNamespace] || './app')) | ||
_setupResolver (namespace) { | ||
this.appNamespace = namespace | ||
debug('%s is the primary namespace', namespace) | ||
@@ -156,7 +157,2 @@ /** | ||
/** | ||
* Setting up the autoloaded directory | ||
*/ | ||
this._fold.ioc.autoload(autoloadDirectory, this.appNamespace) | ||
/** | ||
* Bind directories to resolver, so that we can | ||
@@ -167,6 +163,41 @@ * resolve ioc container paths by passing | ||
this._fold.resolver.directories(DIRECTORIES) | ||
debug('autoloading %s under %s namespace', autoloadDirectory, this.appNamespace) | ||
} | ||
/** | ||
* Registers all directories from the package.json file | ||
* to IoC container as autoloaded. | ||
* | ||
* First namespace/directory key/value pair will be used as | ||
* primary autoloaded directory and doesn't require | ||
* fullnamespaces at different places. | ||
* | ||
* @method _registerAutoloadedDirectories | ||
* | ||
* @return {void} | ||
* | ||
* @private | ||
*/ | ||
_registerAutoloadedDirectories () { | ||
let autoloads = this._packageFile.autoload || {} | ||
/** | ||
* Defining fallback autoload when nothing autoloads | ||
* map is empty | ||
*/ | ||
if (Object.keys(autoloads).length === 0) { | ||
autoloads = { 'App': './app' } | ||
} | ||
Object.keys(autoloads).forEach((namespace, index) => { | ||
const namespaceLocation = path.join(this._appRoot, autoloads[namespace]) | ||
if (index === 0) { | ||
this._setupResolver(namespace) | ||
} | ||
this._fold.ioc.autoload(namespaceLocation, namespace) | ||
debug('autoloading %s under %s namespace', namespaceLocation, namespace) | ||
}) | ||
} | ||
/** | ||
* This method sets the global exception handler for handling exceptions. | ||
@@ -331,3 +362,4 @@ * By default it will rely on a global exceptions handler defined in | ||
try { | ||
require(path.join(this._appRoot, file)) | ||
const filePath = path.isAbsolute(file) ? file : path.join(this._appRoot, file) | ||
require(filePath) | ||
} catch (error) { | ||
@@ -544,3 +576,3 @@ if (error.code !== 'MODULE_NOT_FOUND' || !this._isOptional(file)) { | ||
this._setPackageFile() | ||
this._setupResolver() | ||
this._registerAutoloadedDirectories() | ||
this._registerHelpers() | ||
@@ -552,3 +584,2 @@ this._loadHooksFileIfAny() | ||
this._setupExceptionsHandler() | ||
this._loadPreLoadFiles() | ||
@@ -561,2 +592,4 @@ /** | ||
} | ||
this._loadPreLoadFiles() | ||
} | ||
@@ -563,0 +596,0 @@ |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
Dynamic require
Supply chain riskDynamic require can indicate the package is performing dangerous or unsafe dynamic code execution.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
Dynamic require
Supply chain riskDynamic require can indicate the package is performing dangerous or unsafe dynamic code execution.
Found 1 instance in 1 package
32200
909