From 68c096e68976defbad99605390031f0190b5e450 Mon Sep 17 00:00:00 2001 From: jacoobes Date: Fri, 31 Mar 2023 12:57:07 -0500 Subject: [PATCH] chore: use constant instead of function --- src/commands/help.ts | 4 +--- src/commands/plugins.ts | 21 +++++++++------------ src/index.ts | 2 +- 3 files changed, 11 insertions(+), 16 deletions(-) diff --git a/src/commands/help.ts b/src/commands/help.ts index 9296d5f..5d98a8f 100644 --- a/src/commands/help.ts +++ b/src/commands/help.ts @@ -1,7 +1,6 @@ import { cyanBright, green, magentaBright } from 'colorette'; -export function help() { - return ` +export const help = ` ___ ___ _ __ _ __ / __|/ _ \\ '__| '_ \\ \\__ \\ __/ | | | | | @@ -15,4 +14,3 @@ export function help() { ${green( `If you have any ideas, suggestions, bug reports, kindly join our support server: https://sern.dev/discord` )}`; -} diff --git a/src/commands/plugins.ts b/src/commands/plugins.ts index 05b9716..1902417 100644 --- a/src/commands/plugins.ts +++ b/src/commands/plugins.ts @@ -18,14 +18,14 @@ function dispatchInstall() { } export async function plugins(options: PluginOptions) { - console.log(options) if(options.save) { dispatchSave() } - //Download instead based on names given. Must be a full filename ie: (publish.ts) + //Download instead based on names given. Must be a full filename ie: (publish) if(options.name) { - - + + const pluginSource = await downloa(); + } const e: string[] = (await prompt([await pluginsQ()])).list; if (!e) process.exit(1); @@ -41,16 +41,13 @@ export async function plugins(options: PluginOptions) { ); } -async function downloa(url: string, path: string) { - const format = (res: Response) => res.text() - const data = await fetch(url, { method: 'GET' }) - .then(format) +async function downloa(url: string | URL) { + const formatText = (res: Response) => res.text() + return fetch(url, { method: 'GET' }) + .then(formatText) .catch(() => { throw Error('Download failed! Kindly contact developers') }) - - const fullPath = fromCwd(path) - } async function download(url: string) { @@ -60,7 +57,7 @@ async function download(url: string) { if (!data) throw new Error('Download failed! Kindly contact developers'); - const dir = `${fromCwd('/src/plugins')}`; + const dir = fromCwd('/src/plugins'); const filedir = `${process.cwd()}/src/plugins/${url.split('/').pop()}`; if (!fs.existsSync(dir)) { diff --git a/src/index.ts b/src/index.ts index bbf08f5..d87ede8 100644 --- a/src/index.ts +++ b/src/index.ts @@ -12,7 +12,7 @@ const version: string = '[VI]{{inject}}[/VI]'; program .name('sern') - .description(help()) + .description(help) .version(`sern CLI v${version}`) .exitOverride(() => process.exit(0));