egg-core
Advanced tools
Comparing version 0.1.0 to 0.2.0
0.2.0 / 2016-08-17 | ||
================== | ||
* feat: improve initializer && export Loader | ||
0.1.0 / 2016-08-16 | ||
@@ -3,0 +8,0 @@ ================== |
@@ -268,2 +268,10 @@ 'use strict'; | ||
get FileLoader() { | ||
return FileLoader; | ||
} | ||
get ContextLoader() { | ||
return ContextLoader; | ||
} | ||
} | ||
@@ -270,0 +278,0 @@ |
@@ -122,3 +122,3 @@ 'use strict'; | ||
if (initializer) { | ||
exports = initializer(exports); | ||
exports = initializer(exports, { path: fullpath }); | ||
} | ||
@@ -125,0 +125,0 @@ |
{ | ||
"name": "egg-core", | ||
"version": "0.1.0", | ||
"version": "0.2.0", | ||
"description": "A core Plugable framework based on koa", | ||
"main": "index.js", | ||
"scripts": { | ||
"autod": "autod", | ||
"lint": "eslint lib test *.js", | ||
@@ -33,2 +34,3 @@ "test": "npm run lint && egg-bin test", | ||
"devDependencies": { | ||
"autod": "^2.7.0", | ||
"egg-bin": "1", | ||
@@ -40,6 +42,6 @@ "egg-ci": "1", | ||
"koa-router": "4", | ||
"mm": "1", | ||
"mm": "^2.0.0", | ||
"pedding": "^1.0.0", | ||
"should": "9", | ||
"supertest": "1" | ||
"should": "^11.1.0", | ||
"supertest": "^2.0.0" | ||
}, | ||
@@ -49,3 +51,3 @@ "dependencies": { | ||
"depd": "^1.1.0", | ||
"egg-logger": "^1.1.0", | ||
"egg-logger": "^1.2.0", | ||
"extend": "^3.0.0", | ||
@@ -56,3 +58,3 @@ "globby": "^6.0.0", | ||
"is-type-of": "^1.0.0", | ||
"koa": "^1.2.0", | ||
"koa": "^1.2.1", | ||
"koa-router": "^5.4.0", | ||
@@ -59,0 +61,0 @@ "ready-callback": "^1.0.0", |
@@ -214,11 +214,21 @@ # egg-core | ||
- {String|Array} directory - directories to load | ||
- {Object} target: attach object from loaded files, | ||
- {String} ignore - ignore the files when load | ||
- {Function} initializer - custom file exports | ||
- {Boolean} lowercaseFirst - determine whether the fist letter is lowercase | ||
- {Boolean} override: determine whether override the property when get the same name | ||
- {Boolean} call - determine whether invoke when exports is function | ||
- {Object} inject - an object that be the argument when invoke the function | ||
Param | Type | Description | ||
-------------- | -------------- | ------------------------ | ||
directory | `String/Array` | directories to load | ||
target | `Object` | attach object from loaded files | ||
ignore | `String` | ignore the files when load | ||
initializer | `Function` | custom file exports, receive two parameters, first is the inject object, second is an `options` object that contain `path` | ||
lowercaseFirst | `Boolean` | determine whether the fist letter is lowercase | ||
override | `Boolean` | determine whether override the property when get the same name | ||
call | `Boolean` | determine whether invoke when exports is function | ||
inject | `Object` | an object that be the argument when invoke the function | ||
## Questions & Suggestions | ||
Please open an issue [here](https://github.com/eggjs/egg/issues). | ||
## License | ||
[MIT](LICENSE) | ||
[egg]: https://github.com/eggjs/egg |
'use strict'; | ||
module.exports = class TestClass { | ||
constructor() { | ||
constructor(app, fullpath) { | ||
this.user = { | ||
name: 'kai.fangk', | ||
}; | ||
this.app = app; | ||
this.path = fullpath; | ||
} | ||
} |
@@ -158,4 +158,4 @@ 'use strict'; | ||
ignore: 'util/**', | ||
initializer(exports) { | ||
return new exports(app); | ||
initializer(exports, opt) { | ||
return new exports(app, opt.path); | ||
}, | ||
@@ -165,2 +165,4 @@ }).load(); | ||
app.dao.TestClass.user.should.eql({ name: 'kai.fangk' }); | ||
app.dao.TestClass.app.should.equal(app); | ||
app.dao.TestClass.path.should.equal(path.join(dirBase, 'dao/TestClass.js')); | ||
app.dao.should.have.property('testFunction', { user: { name: 'kai.fangk' } }); | ||
@@ -167,0 +169,0 @@ app.dao.should.have.property('testReturnFunction', { user: { name: 'kai.fangk' } }); |
Major refactor
Supply chain riskPackage has recently undergone a major refactor. It may be unstable or indicate significant internal changes. Use caution when updating to versions that include significant changes.
Found 1 instance in 1 package
New author
Supply chain riskA new npm collaborator published a version of the package for the first time. New collaborators are usually benign additions to a project, but do indicate a change to the security surface area of a package.
Found 1 instance in 1 package
141343
294
4474
234
0
11
Updatedegg-logger@^1.2.0
Updatedkoa@^1.2.1