Skip to content

Commit 29118e5

Browse files
Maledongdead-horse
authored andcommitted
Chore (gitignore, file_loader.test.js): Update files (#195)
1 parent b958870 commit 29118e5

4 files changed

Lines changed: 28 additions & 13 deletions

File tree

.gitignore

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,4 +7,5 @@ npm-debug.log
77
yarn.lock
88
test/fixtures/egg/node_modules/egg-core
99
.idea
10-
.nyc_output
10+
.nyc_output
11+
package-lock.json

lib/egg.js

Lines changed: 24 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -201,7 +201,14 @@ class EggCore extends KoaApplication {
201201
}
202202

203203
/**
204-
* Execute scope after loaded and before app start
204+
* Execute scope after loaded and before app start.
205+
*
206+
* Notice:
207+
* This method is now NOT recommanded and reguarded as a deprecated one,
208+
* For plugin development, we should use `didLoad` instead.
209+
* For application development, we should use `willReady` instead.
210+
*
211+
* @see https://eggjs.org/en/advanced/loader.html#beforestart
205212
*
206213
* @param {Function|GeneratorFunction|AsyncFunction} scope function will execute before app start
207214
*/
@@ -249,8 +256,16 @@ class EggCore extends KoaApplication {
249256
}
250257

251258
/**
252-
* Register a function that will be called when app close
253-
* @param {Function} fn - the function that can be generator function or async function
259+
* Register a function that will be called when app close.
260+
*
261+
* Notice:
262+
* This method is now NOT recommanded directly used,
263+
* Developers SHOULDN'T use app.beforeClose directly now,
264+
* but in the form of class to implement beforeClose instead.
265+
*
266+
* @see https://eggjs.org/en/advanced/loader.html#beforeclose
267+
*
268+
* @param {Function} fn - the function that can be generator function or async function.
254269
*/
255270
beforeClose(fn) {
256271
this.lifecycle.registerBeforeClose(fn);
@@ -317,13 +332,13 @@ class EggCore extends KoaApplication {
317332
* @param {Function} fn The inputted function.
318333
* @return {AsyncFunction} An async promise-based function.
319334
* @example
320-
* ```javascript
321-
* const fn = function* (arg) {
335+
```javascript
336+
const fn = function* (arg) {
322337
return arg;
323338
};
324339
const wrapped = app.toAsyncFunction(fn);
325340
wrapped(true).then((value) => console.log(value));
326-
* ```
341+
```
327342
*/
328343
toAsyncFunction(fn) {
329344
if (!is.generatorFunction(fn)) return fn;
@@ -338,14 +353,14 @@ class EggCore extends KoaApplication {
338353
* @param {Mixed} obj The inputted object.
339354
* @return {Promise} A Promisable result.
340355
* @example
341-
* ```javascript
342-
* const fn = function* (arg) {
356+
```javascript
357+
const fn = function* (arg) {
343358
return arg;
344359
};
345360
const arr = [ fn(1), fn(2) ];
346361
const promise = app.toPromise(arr);
347362
promise.then(res => console.log(res));
348-
* ```
363+
```
349364
*/
350365
toPromise(obj) {
351366
return co(function* () {

lib/lifecycle.js

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,6 @@ const getReady = require('get-ready');
66
const { Ready } = require('ready-callback');
77
const { EventEmitter } = require('events');
88
const debug = require('debug')('egg-core:lifecycle');
9-
109
const INIT = Symbol('Lifycycle#init');
1110
const INIT_READY = Symbol('Lifecycle#initReady');
1211
const DELEGATE_READY_EVENT = Symbol('Lifecycle#delegateReadyEvent');
@@ -83,7 +82,7 @@ class Lifecycle extends EventEmitter {
8382

8483
addFunctionAsBootHook(hook) {
8584
assert(this[INIT] === false, 'do not add hook when lifecycle has been initialized');
86-
// app.js is export as a funciton
85+
// app.js is exported as a function
8786
// call this function in configDidLoad
8887
this[BOOT_HOOKS].push(class Hook {
8988
constructor(app) {

test/loader/file_loader.test.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -118,7 +118,7 @@ describe('test/loader/file_loader.test.js', () => {
118118
assert.deepEqual(instance.getUser(), { name: 'xiaochen.gaoxc' });
119119
});
120120

121-
it.skip('should only load property match the filers', () => {
121+
it('should only load property match the filers', () => {
122122
const app = { middlewares: {} };
123123
new FileLoader({
124124
directory: [

0 commit comments

Comments
 (0)