From e74976a72cce8f9adeddbd92d3b55466b4e84e2a Mon Sep 17 00:00:00 2001 From: Jacob Nguyen <76754747+jacoobes@users.noreply.github.com> Date: Sun, 8 May 2022 22:26:10 -0500 Subject: [PATCH] refactor: Simplifying logic, cleaning up code --- src/commands/test.js | 3 +-- src/index.js | 4 ++-- src/prompts/init.js | 4 +--- 3 files changed, 4 insertions(+), 7 deletions(-) diff --git a/src/commands/test.js b/src/commands/test.js index 4934480..b968606 100644 --- a/src/commands/test.js +++ b/src/commands/test.js @@ -12,6 +12,5 @@ export async function editMain(name) { output.main = name; - const result = () => writeFile(pjLocation, JSON.stringify(output, null, 2)); - return result(); + return writeFile(pjLocation, JSON.stringify(output, null, 2)); } diff --git a/src/index.js b/src/index.js index 3bbfc4e..c9d465f 100644 --- a/src/index.js +++ b/src/index.js @@ -2,9 +2,9 @@ import { init } from './commands/init.js'; const regex = /(?<=--|-)\w+/gm; -const flags = process.argv.slice(2).join(' ').match(regex); - const rawArgs = process.argv.slice(2); +const flags = rawArgs.join(' ').match(regex); + const args = rawArgs .join(' ') .trim() diff --git a/src/prompts/init.js b/src/prompts/init.js index a29ce4b..3daaec9 100644 --- a/src/prompts/init.js +++ b/src/prompts/init.js @@ -61,9 +61,7 @@ export const token = { type: 'password', validate: (/** @type {string} */ token) => - token.match( - /(?mfa\.[a-z0-9_-]{20,})|(?[a-z0-9_-]{23,28}\.[a-z0-9_-]{6,7}\.[a-z0-9_-]{27})/i - )?.length + (/(?mfa\.[a-z0-9_-]{20,})|(?[a-z0-9_-]{23,28}\.[a-z0-9_-]{6,7}\.[a-z0-9_-]{27})/i).test(token) ? true : 'Invalid token', };