Skip to content

Commit

Permalink
fix: fix dao extension in prod
Browse files Browse the repository at this point in the history
  • Loading branch information
killagu committed Apr 8, 2024
1 parent de920c3 commit 26ce0d0
Showing 1 changed file with 9 additions and 2 deletions.
11 changes: 9 additions & 2 deletions plugin/dal/lib/DataSource.ts
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,14 @@ import { EggObject, EggObjectLifeCycleContext } from '@eggjs/tegg-runtime';
import { TableModelManager } from './TableModelManager';
import { MysqlDataSourceManager } from './MysqlDataSourceManager';
import { SqlMapManager } from './SqlMapManager';
import BuiltinModule from 'module';

// Guard against poorly mocked module constructors.
const Module = module.constructor.length > 1
? module.constructor
/* istanbul ignore next */
: BuiltinModule;
const EXTENSION = Object.keys((Module as any)._extensions).find(t => t === '.ts') ? '.ts' : '.js';

@MultiInstanceProto({
accessLevel: AccessLevel.PUBLIC,
Expand All @@ -36,8 +44,7 @@ import { SqlMapManager } from './SqlMapManager';
} catch {
return [];
}

const daos = dirents.filter(t => t.endsWith('DAO.ts'));
const daos = dirents.filter(t => t.endsWith(`DAO${EXTENSION}`));
// eslint-disable-next-line @typescript-eslint/no-var-requires
const daoClazzList = daos.map(t => {
// eslint-disable-next-line @typescript-eslint/no-var-requires
Expand Down

0 comments on commit 26ce0d0

Please sign in to comment.