Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 3 additions & 1 deletion core/aop-decorator/src/decorator/Advice.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,10 @@ import {
EggProtoImplClass,
ObjectInitType,
Prototype,
PrototypeParams,
PrototypeParams, PrototypeUtil,
} from '@eggjs/core-decorator';
import { AdviceInfoUtil } from '../util/AdviceInfoUtil';
import { StackUtil } from '@eggjs/tegg-common-util';

export interface AdviceContext<T = object> {
that: T;
Expand Down Expand Up @@ -62,5 +63,6 @@ export function Advice(param?: PrototypeParams) {
...param,
});
func(constructor);
PrototypeUtil.setFilePath(constructor, StackUtil.getCalleeFromStack(false, 5));
};
}
6 changes: 6 additions & 0 deletions core/aop-decorator/test/AspectMetaBuilder.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ import {
PointcutAdviceOverwriteChildExample,
PointcutAdviceOverwriteParentExample,
} from './fixtures/InheritExample';
import { PrototypeUtil } from '@eggjs/core-decorator';

describe('test/AspectMetaBuild.test.ts', () => {
const crosscutAdviceFactory = new CrosscutAdviceFactory();
Expand Down Expand Up @@ -133,4 +134,9 @@ describe('test/AspectMetaBuild.test.ts', () => {
const aspects = builder.build();
assert(aspects.length === 1);
});

it('should has right file path', () => {
const filePath = PrototypeUtil.getFilePath(CrosscutClassAdviceExample);
assert(filePath === require.resolve('./fixtures/CrosscutExample'));
});
});