mikser-io-layouts 2.3.0 → 2.4.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 +15 -6
  2. package/package.json +2 -2
package/index.js CHANGED
@@ -21,6 +21,7 @@ import {
21
21
  checksumsByCollection,
22
22
  checksum as fileChecksum, checksumOf,
23
23
  useDatabase,
24
+ writeOutput, reportUnchanged,
24
25
  } from 'mikser-io'
25
26
 
26
27
  import { createInspect } from './lib/inspect.js'
@@ -408,12 +409,20 @@ export function layouts(userOptions = {}) {
408
409
 
409
410
  if (!skipWrite) {
410
411
  const destinationFile = path.join(writeBase, entity.destination)
411
- await mkdir(path.dirname(destinationFile), { recursive: true })
412
- try {
413
- await unlink(destinationFile)
414
- } catch { }
415
- await writeFile(destinationFile, output.result)
416
- logger.debug('Layout render finished: %s', entity.destination.replace(runtime.options.workingFolder, ''))
412
+ // writeOutput skips the write when the bytes already on
413
+ // disk are identical. Invalidation is deliberately
414
+ // conservative — an entity that merely READ another
415
+ // re-renders, because the engine cannot know which field
416
+ // was read — so byte-identical output is routine, and
417
+ // rewriting it moved mtime for live-reload, rsync and
418
+ // `find -newer` alike. mkdir/unlink moved inside it.
419
+ const wrote = await writeOutput(destinationFile, output.result)
420
+ if (wrote) {
421
+ logger.debug('Layout render finished: %s', entity.destination.replace(runtime.options.workingFolder, ''))
422
+ } else {
423
+ reportUnchanged(entity)
424
+ logger.debug('Layout render finished, output unchanged: %s', entity.destination.replace(runtime.options.workingFolder, ''))
425
+ }
417
426
  } else {
418
427
  logger.debug('Layout render finished (save:false, bytes only): %s', entity.id)
419
428
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "mikser-io-layouts",
3
- "version": "2.3.0",
3
+ "version": "2.4.0",
4
4
  "description": "SSG-flavor task-production policy for mikser-io. Multi-match layout assignment, per-layout destinations, postprocess chain attachment, layout inspection.",
5
5
  "main": "index.js",
6
6
  "type": "module",
@@ -18,7 +18,7 @@
18
18
  },
19
19
  "homepage": "https://github.com/almero-digital-marketing/mikser-io-layouts#readme",
20
20
  "peerDependencies": {
21
- "mikser-io": "^9.14.0"
21
+ "mikser-io": "^9.18.0"
22
22
  },
23
23
  "dependencies": {
24
24
  "globby": "^14.0.0",