diff --git a/src/commands/node/chopsticks/start.ts b/src/commands/node/chopsticks/start.ts index c79e83da..bde4a77f 100644 --- a/src/commands/node/chopsticks/start.ts +++ b/src/commands/node/chopsticks/start.ts @@ -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 { @@ -16,7 +16,7 @@ export class StartChopsticks extends SwankyCommand { async run(): Promise { const { flags } = await this.parse(StartChopsticks); - swankyNodeCheck(this.swankyConfig); + ensureSwankyNodeInstalled(this.swankyConfig); const chopsticksConfigPath = flags.config ?? this.swankyConfig.node.chopsticks?.configPath; diff --git a/src/commands/node/start.ts b/src/commands/node/start.ts index 6a09fb29..89155083 100644 --- a/src/commands/node/start.ts +++ b/src/commands/node/start.ts @@ -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 { static description = "Start a local node"; @@ -30,7 +30,7 @@ export class StartNode extends SwankyCommand { async run(): Promise { 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`. diff --git a/src/lib/command-utils.ts b/src/lib/command-utils.ts index 53f1040f..accfe86b 100644 --- a/src/lib/command-utils.ts +++ b/src/lib/command-utils.ts @@ -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.'); - } -} \ No newline at end of file diff --git a/src/lib/config.ts b/src/lib/config.ts new file mode 100644 index 00000000..fd98d235 --- /dev/null +++ b/src/lib/config.ts @@ -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.'); + } +} diff --git a/src/lib/index.ts b/src/lib/index.ts index b14b6f9c..2d961da5 100644 --- a/src/lib/index.ts +++ b/src/lib/index.ts @@ -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";