How to use the midway-bin.resolveModule function in midway-bin

To help you get started, we’ve selected a few midway-bin examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github midwayjs / midway / packages / midway-mock / src / mock.ts View on Github external
default: mock.EggMock;
  app: (option?: MidwayApplicationOptions) => MidwayMockApplication;
  cluster: (option?: MidwayApplicationOptions) => MidwayMockApplication;
  // [prop: string]: any
}

/**
 * 只初始化app级别的container
 * agent相关的逻辑使用mm2.app
 * @param options 参数
 */
function mockContainer(options: MidwayApplicationOptions): MockContainer {
  return new MockContainer(options);
}

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

export const mm = Object.assign({}, mock, {
  container: mockContainer,
}) as MidwayMock;

mm.app = (options): MidwayMockApplication => {
  if (process.env.MIDWAY_BASE_DIR && !options.baseDir) { options.baseDir = process.env.MIDWAY_BASE_DIR; }
  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,
    typescript: !!require.extensions['.ts'],
  }, options));
};

mm.cluster = (options) => {

midway-bin

Midway Command Tools

MIT
Latest version published 4 years ago

Package Health Score

64 / 100
Full package analysis