From e71f0ec85b10129c03f2a014343a8da81c1ae251 Mon Sep 17 00:00:00 2001 From: nakyeonko3 Date: Fri, 27 Sep 2024 18:49:27 +0900 Subject: [PATCH] =?UTF-8?q?fix:=20dist/setup.mjs=20=EC=88=98=EC=A0=95=20?= =?UTF-8?q?=20(#74)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - dist/setup.mjs 안에서 실행 될 때 잘못된 경로를 읽는 문제를 해결함 - readByulHookFile 함수는 byul_script 파일을 찾아서 읽고, 읽은 값을 string으로 바꿔서 리턴하는 함수임. - readByulHookFile 함수가 읽는 파일경로는 다음과 같음 1. rootDir/node_modules/byul/dist/byul_script 2. rootDir/../../node_modules/byul/dist/byul_script 3. rootDir/dist/setup.mjs --- dist/setup.mjs | 29 +++++++++++++++++++++-------- 1 file changed, 21 insertions(+), 8 deletions(-) diff --git a/dist/setup.mjs b/dist/setup.mjs index b585fd4..aa2278a 100644 --- a/dist/setup.mjs +++ b/dist/setup.mjs @@ -81,14 +81,27 @@ function writeConfigFile(filePath, defaultConfig) { } function readByulHookFile() { - const byulHookFile = path.join( - rootDir, - "node_modules", - "byul", - "dist", - "byul_script" - ); - return readFileSync(byulHookFile, "utf8"); + const possiblePaths = [ + path.join(rootDir, "node_modules", "byul", "dist", "byul_script"), + path.join( + rootDir, + "..", + "..", + "node_modules", + "byul", + "dist", + "byul_script" + ), + path.join(rootDir, "byul", "dist", "byul_script"), + ]; + + for (const byulHookFile of possiblePaths) { + if (existsSync(byulHookFile)) { + return readFileSync(byulHookFile, "utf8"); + } + } + + throw new Error("Unable to find byul_script file."); } function setupCommitMsgHook() {