-
Notifications
You must be signed in to change notification settings - Fork 29
/
start.ts
39 lines (31 loc) · 1.32 KB
/
start.ts
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
import { Flags } from "@oclif/core";
import { execaCommand } from "execa";
import { SwankyCommand } from "../../../lib/swankyCommand.js";
import { ensureSwankyNodeInstalled } from "../../../lib/index.js";
import { pathExists } from "fs-extra/esm";
import { ConfigError, FileError } from "../../../lib/errors.js";
export class StartChopsticks extends SwankyCommand<typeof StartChopsticks> {
static description = "Start chopsticks";
static flags = {
config: Flags.string({
description: "Path to the chopsticks config file",
}),
};
async run(): Promise<void> {
const { flags } = await this.parse(StartChopsticks);
ensureSwankyNodeInstalled(this.swankyConfig);
const chopsticksConfigPath = flags.config ?? this.swankyConfig.node.chopsticks?.configPath;
if (!chopsticksConfigPath) {
throw new ConfigError(
"Chopsticks config not set in swanky config. Please set it in swanky config or provide the path to the chopsticks config file using --config flag."
);
}
if (!(await pathExists(chopsticksConfigPath))) {
throw new FileError(`Chopsticks config file not found at ${flags.config}`);
}
await execaCommand(`npx @acala-network/chopsticks@latest --config=${chopsticksConfigPath}`, {
stdio: "inherit",
});
this.log("Chopsticks started successfully.");
}
}