@lyrolab/nest-shared 0.0.1 → 0.0.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/database/helpers/find-main-path.d.ts +1 -0
- package/dist/database/helpers/find-main-path.js +23 -0
- package/dist/database/helpers/find-main-path.js.map +1 -0
- package/dist/database/shared-database.module.js +3 -2
- package/dist/database/shared-database.module.js.map +1 -1
- package/dist/tsconfig.build.tsbuildinfo +1 -1
- package/package.json +1 -1
- package/src/database/helpers/find-main-path.ts +22 -0
- package/src/database/shared-database.module.ts +3 -2
package/package.json
CHANGED
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
import { existsSync } from "fs"
|
|
2
|
+
import { dirname, join } from "path"
|
|
3
|
+
|
|
4
|
+
export function findMainPath() {
|
|
5
|
+
const rootPath = findUp("package.json", process.cwd())
|
|
6
|
+
if (!rootPath) throw new Error("package.json not found")
|
|
7
|
+
return rootPath
|
|
8
|
+
}
|
|
9
|
+
|
|
10
|
+
function findUp(path: string, cwd: string) {
|
|
11
|
+
const currentPath = cwd
|
|
12
|
+
const parentPath = dirname(currentPath)
|
|
13
|
+
if (parentPath === currentPath) {
|
|
14
|
+
return null
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
if (existsSync(join(currentPath, path))) {
|
|
18
|
+
return currentPath
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
return findUp(path, parentPath)
|
|
22
|
+
}
|
|
@@ -2,6 +2,7 @@ import { DynamicModule, Module, OnModuleDestroy } from "@nestjs/common"
|
|
|
2
2
|
import { ConfigModule, ConfigService } from "@nestjs/config"
|
|
3
3
|
import { TypeOrmModule, TypeOrmModuleOptions } from "@nestjs/typeorm"
|
|
4
4
|
import { join } from "path"
|
|
5
|
+
import { findMainPath } from "./helpers/find-main-path"
|
|
5
6
|
import { GenericContainer, StartedTestContainer, Wait } from "testcontainers"
|
|
6
7
|
import { DataSource } from "typeorm"
|
|
7
8
|
|
|
@@ -63,11 +64,11 @@ export class SharedDatabaseModule implements OnModuleDestroy {
|
|
|
63
64
|
)}/test`
|
|
64
65
|
|
|
65
66
|
const entities = options.entities || [
|
|
66
|
-
join(
|
|
67
|
+
join(findMainPath(), "**/*.entity{.ts,.js}"),
|
|
67
68
|
]
|
|
68
69
|
|
|
69
70
|
const migrations = options.migrations || [
|
|
70
|
-
join(
|
|
71
|
+
join(findMainPath(), "src/migrations/**/*.{ts,js}"),
|
|
71
72
|
]
|
|
72
73
|
|
|
73
74
|
if (!this.testDataSource) {
|