Comparing version 3.21.0 to 3.21.1
3.21.1 / 2018-05-08 | ||
================== | ||
**fixes** | ||
* [[`f58a142`](http://github.com/eggjs/egg-core/commit/f58a142379ea612e15449bd79b848ccebe143607)] - fix: Loader can be instantiated without timing (#161) (Haoliang Gao <<sakura9515@gmail.com>>) | ||
**others** | ||
* [[`72702d8`](http://github.com/eggjs/egg-core/commit/72702d8ba4dedb39a56185fff6dfaa39b8a96f9b)] - refactor: add timing to extend (#162) (Haoliang Gao <<sakura9515@gmail.com>>) | ||
3.21.0 / 2018-05-07 | ||
@@ -3,0 +12,0 @@ ================== |
@@ -13,2 +13,3 @@ 'use strict'; | ||
const utils = require('../utils'); | ||
const Timing = require('../utils/timing'); | ||
@@ -36,3 +37,3 @@ const REQUIRE_COUNT = Symbol('EggLoader#requireCount'); | ||
this.app = this.options.app; | ||
this.timing = this.app.timing; | ||
this.timing = this.app.timing || new Timing(); | ||
this[REQUIRE_COUNT] = 0; | ||
@@ -295,8 +296,19 @@ | ||
const timingKey = `Require(${this[REQUIRE_COUNT]++}) ${utils.getResolvedFilename(filepath, this.options.baseDir)}`; | ||
this.timing.start(timingKey); | ||
let ret = utils.loadFile(filepath); | ||
// function(arg1, args, ...) {} | ||
if (inject.length === 0) inject = [ this.app ]; | ||
let ret = this.requireFile(filepath); | ||
ret = isFunction(ret) ? ret(...inject) : ret; | ||
return ret; | ||
} | ||
/** | ||
* @param {String} filepath - fullpath | ||
* @return {Object} exports | ||
* @private | ||
*/ | ||
requireFile(filepath) { | ||
const timingKey = `Require(${this[REQUIRE_COUNT]++}) ${utils.getResolvedFilename(filepath, this.options.baseDir)}`; | ||
this.timing.start(timingKey); | ||
const ret = utils.loadFile(filepath); | ||
this.timing.end(timingKey); | ||
@@ -303,0 +315,0 @@ return ret; |
@@ -114,3 +114,3 @@ 'use strict'; | ||
const ext = utils.loadFile(filepath); | ||
const ext = this.requireFile(filepath); | ||
@@ -117,0 +117,0 @@ const properties = Object.getOwnPropertyNames(ext) |
{ | ||
"name": "egg-core", | ||
"version": "3.21.0", | ||
"version": "3.21.1", | ||
"description": "A core Pluggable framework based on koa", | ||
@@ -40,2 +40,3 @@ "main": "index.js", | ||
"egg-ci": "^1.8.0", | ||
"egg-utils": "^2.4.0", | ||
"eslint": "^4.19.1", | ||
@@ -42,0 +43,0 @@ "eslint-config-egg": "^7.0.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
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
98561
2417
14