Skip to content

Commit

Permalink
fix: 2.x fix conflicts (#458)
Browse files Browse the repository at this point in the history
* fix dfs circular depth bug

* remove lodash

* add isProvide
  • Loading branch information
kurten authored Apr 7, 2020
1 parent 5f1243a commit 2b0f44c
Show file tree
Hide file tree
Showing 4 changed files with 22 additions and 12 deletions.
18 changes: 9 additions & 9 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,26 +3,26 @@
"description": "a web framework for complex Node.js application",
"version": "1.0.0",
"devDependencies": {
"@types/chai": "^4.1.7",
"@types/lodash": "^4.14.119",
"@types/mocha": "^5.2.5",
"@types/node": "^10.12.18",
"@types/chai": "^4.2.11",
"@types/lodash": "^4.14.149",
"@types/mocha": "^5.2.7",
"@types/node": "^10.17.18",
"autocannon": "^2.4.1",
"chalk": "^3.0.0",
"debug": "^4.1.1",
"eslint": "^6.1.0",
"gh-pages": "^2.2.0",
"git-hooks": "^1.1.10",
"lerna": "^3.14.1",
"lerna": "^3.20.2",
"lerna-relinker": "^1.4.0",
"node-ab": "0.0.6",
"opencollective": "^1.0.3",
"opencollective-postinstall": "^2.0.2",
"rimraf": "^3.0.0",
"tree-kill": "^1.2.0",
"tslint": "^5.17.0",
"rimraf": "^3.0.2",
"tree-kill": "^1.2.2",
"tslint": "^5.20.1",
"tslint-no-unused-expression-chai": "^0.1.4",
"typescript": "^3.5.1",
"typescript": "^3.8.3",
"vuepress": "^0.14.11"
},
"scripts": {
Expand Down
5 changes: 3 additions & 2 deletions packages/midway-core/src/context/midwayContainer.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,8 @@ import {
ScopeEnum,
PIPELINE_IDENTIFIER,
listModule,
CONFIGURATION_KEY
CONFIGURATION_KEY,
isProvide
} from '@midwayjs/decorator';
import * as is from 'is-type-of';
import { join } from 'path';
Expand Down Expand Up @@ -155,7 +156,7 @@ export class MidwayContainer extends Container implements IMidwayContainer {
}

protected bindModule(module, namespace = '', filePath?: string) {
if (is.class(module)) {
if (is.class(module) && isProvide(module)) {
const providerId = getProviderId(module);
if (providerId) {
this.bind(
Expand Down
7 changes: 7 additions & 0 deletions packages/midway-decorator/src/common/utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -171,3 +171,10 @@ export function saveProviderId(identifier: ObjectIdentifier, target: any, overri

return target;
}
/**
* 是否使用了 saveProviderId
* @param target class
*/
export function isProvide(target: any): boolean {
return Reflect.hasOwnMetadata(TAGGED_CLS, target);
}
4 changes: 3 additions & 1 deletion packages/midway-decorator/test/annotation/provide.test.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@

import { expect } from 'chai';
import { Provide, getProviderId } from '../../src';
import { Provide, getProviderId, isProvide } from '../../src';

@Provide('jjj')
class Test {}
Expand All @@ -9,5 +9,7 @@ describe('/test/annotation/provide.test.ts', () => {
it('provide decorator should be ok', () => {
const id = getProviderId(Test);
expect(id).eq('jjj');

expect(isProvide(Test)).true;
});
});

0 comments on commit 2b0f44c

Please sign in to comment.