From e4e3a3a449e5a087ba28a68b33c04856be4bfbae Mon Sep 17 00:00:00 2001 From: Josh Sherman Date: Tue, 21 Mar 2023 17:22:25 -0500 Subject: [PATCH] feat: move articles to the beginning of alias value Closes #4 --- src/index.mjs | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) diff --git a/src/index.mjs b/src/index.mjs index 6c8f082..c0ba26f 100644 --- a/src/index.mjs +++ b/src/index.mjs @@ -14,7 +14,7 @@ files.forEach((file) => { // Awesome gist that inspired most of the following: // https://gist.github.com/ramiabraham/ff41ba74f2b7104ecece - const value = variable + let value = variable // Removes primary ROM codes .replace(/\[(a|p|b|f|T-|T+|t|h|o|J|!)\]/gi, '') .replace(/\((-|M\d+|U|E|UE)\)/gi, '') @@ -31,5 +31,17 @@ files.forEach((file) => { // Removes Nintendo Entertainment System specific codes .replace(/\[(PC10|VS)\]/gi, ''); + // Replaces suffixes with prefixes + // TODO: Needs to check if the suffix is at the end of the string or has a + // space after it, otherwise games like "Pong, Asteroids & Yars' Revenge" + // will be renamed to "A Pongsteroids & Yars' Revenge" + ['A', 'The'].forEach((prefix) => { + const suffix = `, ${prefix}`; + + if (value.includes(suffix)) { + value = `${prefix} ${value.replace(suffix, '')}`; + } + }); + console.log(`${variable}=${value}`); });