Skip to content

Commit

Permalink
fix: cannot launch
Browse files Browse the repository at this point in the history
If the cwd directory does not exist, spawn will not be able to start normally, so we need to create cwd before starting.

Signed-off-by: Black-Hole1 <[email protected]>
  • Loading branch information
BlackHole1 committed Jan 17, 2024
1 parent a96db96 commit f59d5ae
Showing 1 changed file with 12 additions and 1 deletion.
13 changes: 12 additions & 1 deletion src/darwin.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import cp from "node:child_process";
import fs from "node:fs/promises";
import { Remitter } from "remitter";
import { OVMStatusName } from "./type";
import type { OVMDarwinOptions, OVMEventData, OVMInfo, OVMState } from "./type";
Expand All @@ -14,7 +15,10 @@ export class DarwinOVM {

public static async create(options: OVMDarwinOptions): Promise<DarwinOVM> {
const ovm = new DarwinOVM(options);
await ovm.initEventRestful();
await Promise.all([
ovm.initEventRestful(),
ovm.initPath(),
]);
ovm.initRequest();
return ovm;
}
Expand All @@ -32,6 +36,13 @@ export class DarwinOVM {
this.request = new Request(this.options.socketDir, this.options.name);
}

private async initPath(): Promise<void> {
await fs.mkdir(this.options.targetDir, {
recursive: true,
mode: 0o755,
});
}

public start(): void {
const versions = Object.keys(this.options.versions).map((key) => `${key}=${this.options.versions[key]}`).join(",");

Expand Down

0 comments on commit f59d5ae

Please sign in to comment.