🐛 Fix the array issue in inject
This commit is contained in:
6
bin/helpers/merge.ts
vendored
6
bin/helpers/merge.ts
vendored
@@ -302,13 +302,15 @@ StartupNotify=true
|
|||||||
|
|
||||||
// inject js or css files
|
// inject js or css files
|
||||||
if (inject?.length > 0) {
|
if (inject?.length > 0) {
|
||||||
|
// Ensure inject is an array before calling .every()
|
||||||
|
const injectArray = Array.isArray(inject) ? inject : [inject];
|
||||||
if (
|
if (
|
||||||
!inject.every((item) => item.endsWith('.css') || item.endsWith('.js'))
|
!injectArray.every((item) => item.endsWith('.css') || item.endsWith('.js'))
|
||||||
) {
|
) {
|
||||||
logger.error('The injected file must be in either CSS or JS format.');
|
logger.error('The injected file must be in either CSS or JS format.');
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
const files = inject.map((filepath) =>
|
const files = injectArray.map((filepath) =>
|
||||||
path.isAbsolute(filepath) ? filepath : path.join(process.cwd(), filepath),
|
path.isAbsolute(filepath) ? filepath : path.join(process.cwd(), filepath),
|
||||||
);
|
);
|
||||||
tauriConf.pake.inject = files;
|
tauriConf.pake.inject = files;
|
||||||
|
|||||||
6
dist/cli.js
vendored
6
dist/cli.js
vendored
@@ -548,11 +548,13 @@ StartupNotify=true
|
|||||||
const injectFilePath = path.join(npmDirectory, `src-tauri/src/inject/custom.js`);
|
const injectFilePath = path.join(npmDirectory, `src-tauri/src/inject/custom.js`);
|
||||||
// inject js or css files
|
// inject js or css files
|
||||||
if (inject?.length > 0) {
|
if (inject?.length > 0) {
|
||||||
if (!inject.every((item) => item.endsWith('.css') || item.endsWith('.js'))) {
|
// Ensure inject is an array before calling .every()
|
||||||
|
const injectArray = Array.isArray(inject) ? inject : [inject];
|
||||||
|
if (!injectArray.every((item) => item.endsWith('.css') || item.endsWith('.js'))) {
|
||||||
logger.error('The injected file must be in either CSS or JS format.');
|
logger.error('The injected file must be in either CSS or JS format.');
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
const files = inject.map((filepath) => path.isAbsolute(filepath) ? filepath : path.join(process.cwd(), filepath));
|
const files = injectArray.map((filepath) => path.isAbsolute(filepath) ? filepath : path.join(process.cwd(), filepath));
|
||||||
tauriConf.pake.inject = files;
|
tauriConf.pake.inject = files;
|
||||||
await combineFiles(files, injectFilePath);
|
await combineFiles(files, injectFilePath);
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user