better-svelte-email 0.3.4 → 0.3.5
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/preview/index.js +8 -6
- package/package.json +1 -1
package/dist/preview/index.js
CHANGED
|
@@ -31,8 +31,9 @@ export const emailList = ({ path: emailPath = '/src/lib/emails', root } = {}) =>
|
|
|
31
31
|
try {
|
|
32
32
|
root = process.cwd();
|
|
33
33
|
}
|
|
34
|
-
catch {
|
|
35
|
-
throw new Error('Could not determine the root path of your project. Please pass in the root param manually using process.cwd() or an absolute path'
|
|
34
|
+
catch (err) {
|
|
35
|
+
throw new Error('Could not determine the root path of your project. Please pass in the root param manually using process.cwd() or an absolute path.\nOriginal error: ' +
|
|
36
|
+
err);
|
|
36
37
|
}
|
|
37
38
|
}
|
|
38
39
|
const fullPath = path.join(root, emailPath);
|
|
@@ -48,12 +49,13 @@ export const emailList = ({ path: emailPath = '/src/lib/emails', root } = {}) =>
|
|
|
48
49
|
return { files, path: emailPath };
|
|
49
50
|
};
|
|
50
51
|
const getEmailComponent = async (emailPath, file) => {
|
|
52
|
+
const fileName = `${file}.svelte`;
|
|
51
53
|
try {
|
|
52
54
|
// Import the email component dynamically
|
|
53
|
-
return (await import(/* @vite-ignore */
|
|
55
|
+
return (await import(/* @vite-ignore */ path.join(emailPath, fileName))).default;
|
|
54
56
|
}
|
|
55
|
-
catch {
|
|
56
|
-
throw new Error(`Failed to import email component '${
|
|
57
|
+
catch (err) {
|
|
58
|
+
throw new Error(`Failed to import email component '${fileName}'. Make sure the file exists and includes the <Head /> component.\nOriginal error: ${err}`);
|
|
57
59
|
}
|
|
58
60
|
};
|
|
59
61
|
/**
|
|
@@ -182,7 +184,7 @@ function getFiles(dir, files = []) {
|
|
|
182
184
|
const fileList = fs.readdirSync(dir);
|
|
183
185
|
// Create the full path of the file/directory by concatenating the passed directory and file/directory name
|
|
184
186
|
for (const file of fileList) {
|
|
185
|
-
const name =
|
|
187
|
+
const name = path.join(dir, file);
|
|
186
188
|
// Check if the current file/directory is a directory using fs.statSync
|
|
187
189
|
if (fs.statSync(name).isDirectory()) {
|
|
188
190
|
// If it is a directory, recursively call the getFiles function with the directory path and the files array
|