Skip to content

Commit

Permalink
fix: lazy get default framework (#430)
Browse files Browse the repository at this point in the history
  • Loading branch information
monkindey authored Mar 17, 2020
1 parent bb07b2e commit 140c3df
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions packages/midway-mock/src/mock.ts
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ function mockContainer(options: MidwayApplicationOptions): MockContainer {
return new MockContainer(options);
}

const defaultFramework: string = resolveModule('midway') || resolveModule('midway-mirror');
const getDefaultFramework: () => string = () => resolveModule('midway') || resolveModule('midway-mirror');

export const mm = Object.assign({}, mock, {
container: mockContainer,
Expand All @@ -31,7 +31,7 @@ mm.app = (options): MidwayMockApplication => {
if (process.env.MIDWAY_FRAMEWORK_PATH && !options.framework) { options.framework = process.env.MIDWAY_FRAMEWORK_PATH; }
// @ts-ignore
return mock.app(Object.assign({
framework: options.framework || defaultFramework,
framework: options.framework || getDefaultFramework(),
typescript: !!require.extensions['.ts'],
}, options));
};
Expand All @@ -41,7 +41,7 @@ mm.cluster = (options) => {
if (process.env.MIDWAY_FRAMEWORK_PATH && !options.framework) { options.framework = process.env.MIDWAY_FRAMEWORK_PATH; }
// @ts-ignore
return mock.cluster(Object.assign({
framework: options.framework || defaultFramework,
framework: options.framework || getDefaultFramework(),
typescript: !!require.extensions['.ts'],
}, options));
};
Expand Down

0 comments on commit 140c3df

Please sign in to comment.