Skip to content

Commit

Permalink
chore: swankyNodeCheck renamed ensureSwankyNodeInstalled
Browse files Browse the repository at this point in the history
  • Loading branch information
ipapandinas committed Mar 5, 2024
1 parent 9aa2f3f commit f3120da
Show file tree
Hide file tree
Showing 5 changed files with 13 additions and 10 deletions.
4 changes: 2 additions & 2 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 { swankyNodeCheck } from "../../../lib/index.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> {
Expand All @@ -16,7 +16,7 @@ export class StartChopsticks extends SwankyCommand<typeof StartChopsticks> {
async run(): Promise<void> {
const { flags } = await this.parse(StartChopsticks);

swankyNodeCheck(this.swankyConfig);
ensureSwankyNodeInstalled(this.swankyConfig);

const chopsticksConfigPath = flags.config ?? this.swankyConfig.node.chopsticks?.configPath;

Expand Down
4 changes: 2 additions & 2 deletions src/commands/node/start.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import { Flags } from "@oclif/core";
import { execaCommand } from "execa";
import { SwankyCommand } from "../../lib/swankyCommand.js";
import semver from "semver";
import { swankyNodeCheck } from "../../lib/index.js";
import { ensureSwankyNodeInstalled } from "../../lib/index.js";
export class StartNode extends SwankyCommand<typeof StartNode> {
static description = "Start a local node";

Expand Down Expand Up @@ -30,7 +30,7 @@ export class StartNode extends SwankyCommand<typeof StartNode> {
async run(): Promise<void> {
const { flags } = await this.parse(StartNode);

swankyNodeCheck(this.swankyConfig);
ensureSwankyNodeInstalled(this.swankyConfig);

// Run persistent mode by default. non-persistent mode in case flag is provided.
// Non-Persistent mode (`--dev`) allows all CORS origin, without `--dev`, users need to specify origins by `--rpc-cors`.
Expand Down
6 changes: 0 additions & 6 deletions src/lib/command-utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -207,9 +207,3 @@ export function configName(): string {

return process.env.SWANKY_CONFIG?.split("/").pop() ?? DEFAULT_CONFIG_NAME;
}

export function swankyNodeCheck(config: SwankyConfig){
if(config.node.localPath === "") {
throw new FileError('Swanky node is not installed. Please run `swanky node:install` first.');
}
}
8 changes: 8 additions & 0 deletions src/lib/config.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
import { SwankyConfig } from "../index.js";
import { FileError } from "./errors.js";

export function ensureSwankyNodeInstalled(config: SwankyConfig) {
if (config.node.localPath === "") {
throw new FileError('Swanky node is not installed. Please run `swanky node:install` first.');
}
}
1 change: 1 addition & 0 deletions src/lib/index.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
export * from "./account.js";
export * from "./command-utils.js";
export * from "./config.js";
export * as consts from "./consts.js";
export * from "./crypto.js";
export * from "./nodeInfo.js";
Expand Down

0 comments on commit f3120da

Please sign in to comment.