Skip to content

Commit

Permalink
docs: add plugin.js description (#1499)
Browse files Browse the repository at this point in the history
  • Loading branch information
atian25 authored and popomore committed Oct 11, 2017
1 parent 0a7ba95 commit 6846bad
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 8 deletions.
4 changes: 4 additions & 0 deletions docs/source/zh-cn/advanced/plugin.md
Original file line number Diff line number Diff line change
Expand Up @@ -80,6 +80,10 @@ title: 插件开发
}
```

3. 插件没有 `plugin.js`
- `eggPlugin.dependencies` 只是用于声明依赖关系,而不是引入插件或开启插件。
- 如果期望统一管理多个插件的开启和配置,可以在[上层框架](./framework.md)处理。

## 插件的依赖管理

和中间件不同,插件是自己管理依赖的。应用在加载所有插件前会预先从它们的 `package.json` 中读取 `eggPlugin > dependencies``eggPlugin > optionalDependencies` 节点,然后根据依赖关系计算出加载顺序,举个例子,下面三个插件的加载顺序就应该是 `c => b => a`
Expand Down
17 changes: 9 additions & 8 deletions test/lib/core/httpclient.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -179,6 +179,7 @@ describe('test/lib/core/httpclient.test.js', () => {
});

describe('httpclient tracer', () => {
const url = 'https://eggjs.org/';
let app;
before(() => {
app = utils.app('apps/httpclient-tracer');
Expand All @@ -201,7 +202,7 @@ describe('test/lib/core/httpclient.test.js', () => {
resTracer = options.req.args.tracer;
});

let res = yield httpclient.request('https://www.alipay.com', {
let res = yield httpclient.request(url, {
method: 'GET',
});

Expand All @@ -214,7 +215,7 @@ describe('test/lib/core/httpclient.test.js', () => {
reqTracer = null;
resTracer = null;

res = yield httpclient.request('https://www.alipay.com');
res = yield httpclient.request(url);

assert(res.status === 200);
assert(reqTracer === resTracer);
Expand All @@ -237,7 +238,7 @@ describe('test/lib/core/httpclient.test.js', () => {
resTracer = options.req.args.tracer;
});

const res = yield httpclient.request('https://www.alipay.com', {
const res = yield httpclient.request(url, {
method: 'GET',
});

Expand All @@ -262,7 +263,7 @@ describe('test/lib/core/httpclient.test.js', () => {
resTracer = options.req.args.tracer;
});

let res = yield httpclient.request('https://www.alipay.com', {
let res = yield httpclient.request(url, {
method: 'GET',
});

Expand All @@ -273,7 +274,7 @@ describe('test/lib/core/httpclient.test.js', () => {

reqTracer = null;
resTracer = null;
res = yield httpclient.request('https://www.alipay.com', {
res = yield httpclient.request(url, {
method: 'GET',
ctx: {},
tracer: {
Expand All @@ -287,7 +288,7 @@ describe('test/lib/core/httpclient.test.js', () => {

reqTracer = null;
resTracer = null;
res = yield httpclient.request('https://www.alipay.com', {
res = yield httpclient.request(url, {
method: 'GET',
ctx: {
tracer: {
Expand Down Expand Up @@ -324,7 +325,7 @@ describe('test/lib/core/httpclient.test.js', () => {
resTracers.push(options.req.args.tracer);
});

let res = yield httpclient.request('https://www.alipay.com', {
let res = yield httpclient.request(url, {
method: 'GET',
});
assert(res.status === 200);
Expand Down Expand Up @@ -358,7 +359,7 @@ describe('test/lib/core/httpclient.test.js', () => {

yield app.ready();

res = yield httpclient.request('https://www.alipay.com', {
res = yield httpclient.request(url, {
method: 'GET',
});
assert(res.status === 200);
Expand Down

0 comments on commit 6846bad

Please sign in to comment.