@travetto/email-compiler 3.3.0 → 3.3.1

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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@travetto/email-compiler",
3
- "version": "3.3.0",
3
+ "version": "3.3.1",
4
4
  "description": "Email compiling module",
5
5
  "keywords": [
6
6
  "email",
@@ -1,6 +1,6 @@
1
1
  import fs from 'fs/promises';
2
2
 
3
- import { RootIndex, path } from '@travetto/manifest';
3
+ import { IndexedModule, RootIndex, path } from '@travetto/manifest';
4
4
  import { YamlUtil } from '@travetto/yaml';
5
5
 
6
6
  interface ConfigType {
@@ -39,13 +39,18 @@ export class $EditorConfig {
39
39
  },
40
40
  };
41
41
 
42
+ #getEmailConfig(mod: IndexedModule): string {
43
+ return this.#configFile[mod.name] ??= path.resolve(mod.sourcePath, 'resources/email/dev.yml');
44
+ }
45
+
42
46
  /**
43
47
  *
44
48
  */
45
49
  async get(file: string): Promise<ConfigType> {
46
50
  try {
47
- const mod = RootIndex.getModuleFromSource(file)!.name;
48
- const content = await fs.readFile(this.#configFile[mod], 'utf8');
51
+ const mod = RootIndex.getModuleFromSource(file)!;
52
+ const resolved = this.#getEmailConfig(mod);
53
+ const content = await fs.readFile(resolved, 'utf8');
49
54
  return YamlUtil.parse<ConfigType>(content);
50
55
  } catch {
51
56
  // eslint-disable-next-line @typescript-eslint/consistent-type-assertions
@@ -70,7 +75,7 @@ export class $EditorConfig {
70
75
  async ensureConfig(file: string): Promise<string> {
71
76
  console.log('Ensuring config', file);
72
77
  const mod = RootIndex.getModuleFromSource(file)!;
73
- const resolved = this.#configFile[mod.name] ??= path.resolve(mod.sourcePath, 'resources/email/dev.yml');
78
+ const resolved = this.#getEmailConfig(mod);
74
79
  if (!(await fs.stat(resolved).catch(() => { }))) {
75
80
  await fs.mkdir(path.dirname(resolved), { recursive: true });
76
81
  await fs.writeFile(resolved, this.getDefaultConfig(), { encoding: 'utf8' });