Skip to content

Commit ece9427

Browse files
committed
fix: check vm status
1 parent bd9ef98 commit ece9427

File tree

3 files changed

+39
-37
lines changed

3 files changed

+39
-37
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.3.4",
3+
"version": "0.3.5",
44
"main": "dist/index.js",
55
"types": "dist/index.d.ts",
66
"description": "Node wrapper for nerdctl",

src/index.ts

Lines changed: 36 additions & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -20,37 +20,39 @@ export function factory(path: string = process.cwd()): BaseBackend {
2020
}
2121
}
2222

23-
if (process.env.NODE_ENV === "development") {
24-
async function test() {
25-
const IMAGE_NAME = "hello-world";
26-
const CONTAINER_NAME = "hello";
27-
28-
const vm = factory();
29-
30-
if (!(await vm.checkVM())) {
31-
await vm.initVM();
32-
}
33-
34-
vm.on(events.IMAGE_PULL_START, () => {});
35-
vm.on(events.IMAGE_PULL_OUTPUT, (data) => {
36-
console.log(data);
37-
});
38-
vm.on(events.IMAGE_PULL_END, (data) => {
39-
console.log(data);
40-
});
41-
vm.on(events.CONTAINER_RUN_OUTPUT, (data) => {
42-
console.log(data);
43-
});
44-
45-
await vm.pullImage(IMAGE_NAME);
46-
47-
const images = await vm.getImages();
48-
console.log(images);
49-
50-
await vm.run(IMAGE_NAME, { name: CONTAINER_NAME });
51-
await vm.stop(CONTAINER_NAME);
52-
await vm.remove(CONTAINER_NAME);
53-
}
54-
55-
test();
56-
}
23+
// if (process.env.NODE_ENV === "development") {
24+
// async function test() {
25+
// const IMAGE_NAME = "hello-world";
26+
// const CONTAINER_NAME = "hello";
27+
28+
// const vm = factory();
29+
30+
// console.log(await vm.checkVM());
31+
32+
// if (!(await vm.checkVM())) {
33+
// await vm.initVM();
34+
// }
35+
36+
// vm.on(events.IMAGE_PULL_START, () => {});
37+
// vm.on(events.IMAGE_PULL_OUTPUT, (data) => {
38+
// console.log(data);
39+
// });
40+
// vm.on(events.IMAGE_PULL_END, (data) => {
41+
// console.log(data);
42+
// });
43+
// vm.on(events.CONTAINER_RUN_OUTPUT, (data) => {
44+
// console.log(data);
45+
// });
46+
47+
// await vm.pullImage(IMAGE_NAME);
48+
49+
// const images = await vm.getImages();
50+
// console.log(images);
51+
52+
// await vm.run(IMAGE_NAME, { name: CONTAINER_NAME });
53+
// await vm.stop(CONTAINER_NAME);
54+
// await vm.remove(CONTAINER_NAME);
55+
// }
56+
57+
// test();
58+
// }

src/vms/lima.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -279,7 +279,7 @@ export default class LimaBackend extends BaseBackend {
279279
async checkVM(): Promise<boolean> {
280280
try {
281281
await fs.promises.access(this.limactl, fs.constants.X_OK);
282-
return (await this.status)!.name === "Running";
282+
return (await this.status)!.status === "Running";
283283
} catch (ex: any) {
284284
return false;
285285
}
@@ -289,7 +289,7 @@ export default class LimaBackend extends BaseBackend {
289289
this.emit(events.VM_INIT_START);
290290

291291
if (!!(await this.status)) {
292-
await this.lima("start", "--tty=false", this.instance);
292+
await this.lima("start", this.instance);
293293
return true;
294294
}
295295

0 commit comments

Comments
 (0)