From c6bea92bbbc8c96b7488b8ad2af8ea01020752b9 Mon Sep 17 00:00:00 2001 From: dawn-lc <30336566+dawn-lc@users.noreply.github.com> Date: Sat, 10 May 2025 21:06:44 +0800 Subject: [PATCH 1/2] =?UTF-8?q?=F0=9F=90=9B=20fix=20inject=20single=20file?= =?UTF-8?q?=20error?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: dawn-lc <30336566+dawn-lc@users.noreply.github.com> --- bin/helpers/merge.ts | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/bin/helpers/merge.ts b/bin/helpers/merge.ts index 369dfa82e..1a076771e 100644 --- a/bin/helpers/merge.ts +++ b/bin/helpers/merge.ts @@ -185,7 +185,14 @@ export async function mergeConfig(url: string, options: PakeAppOptions, tauriCon const injectFilePath = path.join(npmDirectory, `src-tauri/src/inject/custom.js`); // inject js or css files - if (inject?.length > 0) { + let injects = [] + if (inject && typeof inject === 'string') { + injects.push(inject); + } + if (inject && Array.isArray(inject)) { + injects = [...inject, ...injects] + } + if (injects.length > 0) { if (!inject.every(item => item.endsWith('.css') || item.endsWith('.js'))) { logger.error('The injected file must be in either CSS or JS format.'); return; From 78cc2e9eb054b41d858a63905a2541301ff14eef Mon Sep 17 00:00:00 2001 From: dawn-lc <30336566+dawn-lc@users.noreply.github.com> Date: Sat, 10 May 2025 21:25:11 +0800 Subject: [PATCH 2/2] =?UTF-8?q?=F0=9F=90=9B=20fix=20inject=20single=20file?= =?UTF-8?q?=20error?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: dawn-lc <30336566+dawn-lc@users.noreply.github.com> --- bin/helpers/merge.ts | 9 +++------ 1 file changed, 3 insertions(+), 6 deletions(-) diff --git a/bin/helpers/merge.ts b/bin/helpers/merge.ts index 1a076771e..d94bf8a18 100644 --- a/bin/helpers/merge.ts +++ b/bin/helpers/merge.ts @@ -185,19 +185,16 @@ export async function mergeConfig(url: string, options: PakeAppOptions, tauriCon const injectFilePath = path.join(npmDirectory, `src-tauri/src/inject/custom.js`); // inject js or css files - let injects = [] + let injects = inject && Array.isArray(inject) ? inject : [] if (inject && typeof inject === 'string') { injects.push(inject); } - if (inject && Array.isArray(inject)) { - injects = [...inject, ...injects] - } if (injects.length > 0) { - if (!inject.every(item => item.endsWith('.css') || item.endsWith('.js'))) { + if (!injects.every(item => item.endsWith('.css') || item.endsWith('.js'))) { logger.error('The injected file must be in either CSS or JS format.'); return; } - const files = inject.map(filepath => (path.isAbsolute(filepath) ? filepath : path.join(process.cwd(), filepath))); + const files = injects.map(filepath => (path.isAbsolute(filepath) ? filepath : path.join(process.cwd(), filepath))); tauriConf.pake.inject = files; await combineFiles(files, injectFilePath); } else {