()
| 57 | } |
| 58 | |
| 59 | private async getSnapshotPath(): Promise<string> { |
| 60 | if (!this.#snapshotPath) { |
| 61 | const { fs } = await import('@mikro-orm/core/fs-utils'); |
| 62 | // for snapshots, we always want to use the path based on `emit` option, regardless of whether we run in TS context |
| 63 | /* v8 ignore next */ |
| 64 | const snapshotPath = this.options.emit === 'ts' && this.options.pathTs ? this.options.pathTs : this.options.path!; |
| 65 | const absoluteSnapshotPath = fs.absolutePath(snapshotPath, this.config.get('baseDir')); |
| 66 | const dbName = this.config.get('dbName')!.replace(/\\/g, '/').split('/').pop()!.replace(/:/g, ''); |
| 67 | const snapshotName = this.options.snapshotName ?? `.snapshot-${dbName}`; |
| 68 | this.#snapshotPath = fs.normalizePath(absoluteSnapshotPath, `${snapshotName}.json`); |
| 69 | } |
| 70 | |
| 71 | return this.#snapshotPath; |
| 72 | } |
| 73 | |
| 74 | protected override async init(): Promise<void> { |
| 75 | if (this.initialized) { |
no test coverage detected