Skip to content

Commit

Permalink
fix: remove duplicate runtime environment checks
Browse files Browse the repository at this point in the history
  • Loading branch information
tada5hi committed Jan 18, 2024
1 parent d0e83e6 commit 25db92a
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 14 deletions.
16 changes: 5 additions & 11 deletions src/data-source/find/module.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,20 +8,17 @@ import path from 'node:path';
import type { DataSource } from 'typeorm';
import { InstanceChecker } from 'typeorm';
import {
CodeTransformation,
adjustFilePath,
isCodeTransformation,
isPromise, readTSConfig,
isPromise,
readTSConfig,
safeReplaceWindowsSeparator,
} from '../../utils';
import type { DataSourceFindOptions } from './type';
import type { TSConfig } from '../../utils';

export async function findDataSource(
context?: DataSourceFindOptions,
context: DataSourceFindOptions = {},
) : Promise<DataSource | undefined> {
context = context || {};

let tsconfig : TSConfig | undefined;
if (!context.preserveFilePaths) {
if (isObject(context.tsconfig)) {
Expand Down Expand Up @@ -57,7 +54,7 @@ export async function findDataSource(
}

if (!context.preserveFilePaths) {
directory = await adjustFilePath(directory);
directory = await adjustFilePath(directory, tsconfig);
}
}

Expand All @@ -78,10 +75,7 @@ export async function findDataSource(

files.push(...lookupPaths);

if (
!context.preserveFilePaths &&
!isCodeTransformation(CodeTransformation.JUST_IN_TIME)
) {
if (!context.preserveFilePaths) {
for (let j = 0; j < files.length; j++) {
files[j] = await adjustFilePath(files[j], tsconfig);
}
Expand Down
4 changes: 1 addition & 3 deletions src/data-source/options/module.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,10 +16,8 @@ import {
* @param context
*/
export async function buildDataSourceOptions(
context?: DataSourceOptionsBuildContext,
context: DataSourceOptionsBuildContext = {},
) : Promise<DataSourceOptions> {
context = context ?? {};

const directory : string = context.directory || process.cwd();

let tsconfig : TSConfig | undefined;
Expand Down

0 comments on commit 25db92a

Please sign in to comment.