Skip to content

Commit

Permalink
fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
prxgr4mm3r committed Feb 29, 2024
1 parent 9b673d1 commit 9c888dd
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 7 deletions.
4 changes: 2 additions & 2 deletions src/commands/node/chopsticks/init.ts
Original file line number Diff line number Diff line change
Expand Up @@ -23,15 +23,15 @@ export class InitChopsticks extends SwankyCommand<typeof InitChopsticks> {
await this.spinner.runCommand(
() =>
copyChopsticksTemplateFile(chopsticksTemplatePath, configPath),
"Copying template files",
"Copying Chopsticks template files...",
);

await this.spinner.runCommand(async () => {
const newLocalConfig = new ConfigBuilder(localConfig)
.addChopsticks(path.resolve(projectPath, "node", "config", chopsticksConfig))
.build();
await this.storeConfig(newLocalConfig, "local");
}, "Writing config");
}, "Updating Swanky configuration with Chopsticks settings...");

this.log("Chopsticks config initialized successfully");
}
Expand Down
12 changes: 7 additions & 5 deletions src/commands/node/chopsticks/start.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { Flags } from "@oclif/core";
import { execaCommand } from "execa";
import { SwankyCommand } from "../../../lib/swankyCommand.js";
import { pathExistsSync } from "fs-extra/esm";
import { pathExists } from "fs-extra/esm";
import { ConfigError, FileError } from "../../../lib/errors.js";
import { ensureSwankyNodeInstalled } from "../../../lib/config.js";
export class StartChopsticks extends SwankyCommand<typeof StartChopsticks> {
Expand All @@ -18,16 +18,18 @@ export class StartChopsticks extends SwankyCommand<typeof StartChopsticks> {

ensureSwankyNodeInstalled(this.swankyConfig);

if(!this.swankyConfig.node.chopsticks && !flags.chopsticksConfigPath) {
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 (flags.chopsticksConfigPath && !pathExistsSync(flags.chopsticksConfigPath)) {
throw new FileError(`Chopsticks config file not found at ${flags.chopsticksConfigPath}`);
if (!(await pathExists(chopsticksConfigPath))) {
throw new FileError(`Chopsticks config file not found at ${flags.config}`);
}

await execaCommand(
`npx @acala-network/chopsticks@latest --config=${flags.chopsticksConfigPath ?? this.swankyConfig.node.chopsticks!.configPath}`,
`npx @acala-network/chopsticks@latest --config=${chopsticksConfigPath}`,
{
stdio: "inherit",
}
Expand Down

0 comments on commit 9c888dd

Please sign in to comment.