Skip to content

Commit 8e5c1da

Browse files
committed
refactor: change return type of run command
1 parent a2bd5a1 commit 8e5c1da

File tree

3 files changed

+10
-25
lines changed

3 files changed

+10
-25
lines changed

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "nerdctl",
3-
"version": "0.0.6",
3+
"version": "0.0.7",
44
"main": "dist/index.js",
55
"types": "dist/index.d.ts",
66
"description": "Node wrapper for nerdctl",

src/vms/base.ts

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -69,12 +69,9 @@ export default abstract class BaseBackend {
6969
abstract login(
7070
flags?: LoginCommandFlags,
7171
server?: string
72-
): Promise<ExecResult>;
72+
): Promise<ShellString>;
7373

74-
abstract run(
75-
image: string,
76-
flags?: RunCommandFlags
77-
): Promise<ExecResult | string>;
74+
abstract run(image: string, flags?: RunCommandFlags): Promise<ChildProcess>;
7875

7976
abstract stop(
8077
container: string | string[],

src/vms/lima.ts

Lines changed: 7 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -18,34 +18,22 @@ export default class LimaBackend extends BaseBackend {
1818
async start(): Promise<void> {}
1919

2020
//#region registry
21-
async login(flags?: LoginCommandFlags, server?: string): Promise<ExecResult> {
21+
async login(
22+
flags?: LoginCommandFlags,
23+
server?: string
24+
): Promise<ShellString> {
2225
const command = `${this.container} login ${this.mergeFlags(
2326
flags
2427
)} ${server}`;
2528

26-
return await this.exec(command, { async: false });
29+
return (await this.exec(command, { async: false })) as ShellString;
2730
}
2831
//#endregion
2932

3033
//#region containers
31-
async run(
32-
image: string,
33-
flags?: RunCommandFlags
34-
): Promise<ExecResult | string> {
34+
async run(image: string, flags?: RunCommandFlags): Promise<ChildProcess> {
3535
const command = `${this.container} run ${this.mergeFlags(flags)} ${image}`;
36-
37-
if (!flags?.detach) {
38-
return await this.exec(command, { async: false });
39-
}
40-
41-
const child = (await this.exec(command)) as ChildProcess;
42-
43-
return new Promise((resove, reject) => {
44-
child.stdout!.on("data", (data) => {
45-
if (!data) reject("");
46-
resove(data);
47-
});
48-
});
36+
return (await this.exec(command)) as ChildProcess;
4937
}
5038

5139
async stop(

0 commit comments

Comments
 (0)