mikser-io-post-mjml 1.0.0 → 2.0.0

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.
Files changed (2) hide show
  1. package/index.js +5 -12
  2. package/package.json +2 -2
package/index.js CHANGED
@@ -2,6 +2,11 @@ import mjml2html from 'mjml'
2
2
  import { readFile } from 'node:fs/promises'
3
3
  import path from 'node:path'
4
4
 
5
+ // Declare the produced file extension so mikser-io can compute the
6
+ // destination correctly even though the postprocessor name and the
7
+ // output extension differ. Requires mikser-io >= 6.3.
8
+ export const output = 'html'
9
+
5
10
  export async function postprocess({ entity, options, config, logger }) {
6
11
  const sourcePath = path.join(options.outputFolder, entity.origin)
7
12
  const source = await readFile(sourcePath, 'utf8')
@@ -17,17 +22,5 @@ export async function postprocess({ entity, options, config, logger }) {
17
22
  }
18
23
  }
19
24
 
20
- // The default postprocessor convention names the output extension after the
21
- // postprocessor key (`.mjml` here). MJML actually produces HTML — rewrite
22
- // the destination so the writer emits `*.html`.
23
- if (entity.destination?.endsWith('.mjml')) {
24
- const desired = entity.destination.slice(0, -'.mjml'.length) + '.html'
25
- // Avoid the origin/destination collision (e.g. layout `name.html-mjml.hbs`
26
- // gives origin=`name.html`, which is also the desired output path).
27
- // Clearing origin prevents onComplete from unlinking our final file.
28
- if (desired === entity.origin) entity.origin = undefined
29
- entity.destination = desired
30
- }
31
-
32
25
  return html
33
26
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "mikser-io-post-mjml",
3
- "version": "1.0.0",
3
+ "version": "2.0.0",
4
4
  "description": "",
5
5
  "main": "index.js",
6
6
  "type": "module",
@@ -16,7 +16,7 @@
16
16
  },
17
17
  "homepage": "https://github.com/almero-digital-marketing/mikser-io-post-mjml#readme",
18
18
  "peerDependencies": {
19
- "mikser-io": "^6.0.0"
19
+ "mikser-io": "^6.3.0"
20
20
  },
21
21
  "dependencies": {
22
22
  "mjml": "^5.2.1"