From f3120daa4ee652b9e03ba72bccf0141d0ea3812a Mon Sep 17 00:00:00 2001 From: Igor Papandinas Date: Tue, 5 Mar 2024 14:09:49 +0100 Subject: [PATCH] chore: swankyNodeCheck renamed ensureSwankyNodeInstalled --- src/commands/node/chopsticks/start.ts | 4 ++-- src/commands/node/start.ts | 4 ++-- src/lib/command-utils.ts | 6 ------ src/lib/config.ts | 8 ++++++++ src/lib/index.ts | 1 + 5 files changed, 13 insertions(+), 10 deletions(-) create mode 100644 src/lib/config.ts 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";