chokibasic 1.1.1 → 1.1.2

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": "chokibasic",
3
- "version": "1.1.1",
3
+ "version": "1.1.2",
4
4
  "description": "Basic chokidar watcher + pxpros + esbuild + sass + csso helpers",
5
5
  "main": "index.js",
6
6
  "types": "index.d.ts",
package/readme.md CHANGED
@@ -47,6 +47,9 @@ process.on("SIGINT", async () => {
47
47
 
48
48
  ## Changelog
49
49
 
50
+ ### Version 1.1.2
51
+ - exportDist: Add date remplacement for sitemap.xml
52
+
50
53
  ### Version 1.1.1
51
54
  - Update dependancy: pxpros 1.0.4
52
55
 
package/src/watcher.js CHANGED
@@ -361,6 +361,7 @@ async function copyFilePreserveTree(absSrc, src, dist, ig) {
361
361
  async function walkAndCopy(dir, src, dest, ig, stats, banner = null) {
362
362
  const entries = await fsprom.readdir(dir, { withFileTypes: true });
363
363
  const bannerContent = (await fsprom.readFile(banner || path.join(__dirname, 'banner.txt'), 'utf8')).replace(/###DATE###/, formatFrDate());
364
+ const today = (d => `${d.getFullYear()}-${String(d.getMonth()+1).padStart(2,'0')}-${String(d.getDate()).padStart(2,'0')}`)(new Date());
364
365
 
365
366
  for (const de of entries) {
366
367
  const abs = path.join(dir, de.name);
@@ -381,6 +382,7 @@ async function walkAndCopy(dir, src, dest, ig, stats, banner = null) {
381
382
  else if (lower.endsWith('.html')) await fsprom.writeFile(copied, "<!--\n\n" + bannerContent + "\n\n\-->\n" + (await fsprom.readFile(copied, 'utf8'))
382
383
  .replaceAll(/###YEAR###/g, (new Date).getFullYear())
383
384
  .replaceAll(/###TIMESTAMP###/g, Math.floor(Date.now() / 1000)), "utf8");
385
+ else if (lower.endsWith('sitemap.xml')) await fsprom.writeFile(copied, (await fsprom.readFile(copied, 'utf8')).replaceAll(/###TODAY###/g, today), "utf8");
384
386
  stats.copied++;
385
387
  }
386
388
  else stats.skipped++;