Skip to content

Commit 3c00188

Browse files
authored
Fix import of ES module open (#491)
1 parent 53f8146 commit 3c00188

File tree

4 files changed

+14
-9
lines changed

4 files changed

+14
-9
lines changed

.changeset/large-donuts-sniff.md

+5
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
'@relate/cli': patch
3+
---
4+
5+
Fix ES import of open package

packages/cli/src/modules/dbms/open.module.ts

+3-3
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
import {Inject, Module, OnApplicationBootstrap} from '@nestjs/common';
22
import {SystemModule, SystemProvider} from '@relate/common';
3-
import {openApp} from 'open';
43

54
import OpenCommand from '../../commands/dbms/open';
65
import {isInteractive} from '../../stdin';
@@ -18,10 +17,11 @@ export class OpenModule implements OnApplicationBootstrap {
1817
@Inject(SystemProvider) protected readonly systemProvider: SystemProvider,
1918
) {}
2019

21-
logOrOpen(path: string): void {
20+
async logOrOpen(path: string): Promise<void> {
2221
if (this.parsed.flags.log) {
2322
this.utils.log(path);
2423
} else {
24+
const {openApp} = await import('open');
2525
openApp(path);
2626
}
2727
}
@@ -43,6 +43,6 @@ export class OpenModule implements OnApplicationBootstrap {
4343
throw new Error(`DBMS ${dbmsId} could not be opened`);
4444
}
4545

46-
this.logOrOpen(dbms.rootPath);
46+
await this.logOrOpen(dbms.rootPath);
4747
}
4848
}

packages/cli/src/modules/environment/open.module.ts

+3-3
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
import {Inject, Module, OnApplicationBootstrap} from '@nestjs/common';
22
import {SystemModule, SystemProvider} from '@relate/common';
3-
import {openApp} from 'open';
43

54
import OpenCommand from '../../commands/environment/open';
65

@@ -16,10 +15,11 @@ export class OpenModule implements OnApplicationBootstrap {
1615
@Inject(SystemProvider) protected readonly systemProvider: SystemProvider,
1716
) {}
1817

19-
logOrOpen(path: string): void {
18+
async logOrOpen(path: string): Promise<void> {
2019
if (this.parsed.flags.log) {
2120
this.utils.log(path);
2221
} else {
22+
const {openApp} = await import('open');
2323
openApp(path);
2424
}
2525
}
@@ -29,6 +29,6 @@ export class OpenModule implements OnApplicationBootstrap {
2929
const {environment: environmentId} = args;
3030
const environment = await this.systemProvider.getEnvironment(environmentId);
3131

32-
this.logOrOpen(environment.configPath);
32+
await this.logOrOpen(environment.configPath);
3333
}
3434
}

packages/cli/src/modules/project/open.module.ts

+3-3
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
import {OnApplicationBootstrap, Module, Inject} from '@nestjs/common';
22
import {SystemModule, SystemProvider} from '@relate/common';
3-
import {openApp} from 'open';
43

54
import {selectProjectPrompt} from '../../prompts';
65
import OpenCommand from '../../commands/project/open';
@@ -17,10 +16,11 @@ export class OpenModule implements OnApplicationBootstrap {
1716
@Inject(SystemProvider) protected readonly systemProvider: SystemProvider,
1817
) {}
1918

20-
logOrOpen(path: string): void {
19+
async logOrOpen(path: string): Promise<void> {
2120
if (this.parsed.flags.log) {
2221
this.utils.log(path);
2322
} else {
23+
const {openApp} = await import('open');
2424
openApp(path);
2525
}
2626
}
@@ -33,6 +33,6 @@ export class OpenModule implements OnApplicationBootstrap {
3333

3434
const project = await environment.projects.get(projectId);
3535

36-
this.logOrOpen(project.root);
36+
await this.logOrOpen(project.root);
3737
}
3838
}

0 commit comments

Comments
 (0)