Skip to content

Commit

Permalink
Use native promise verion of the function
Browse files Browse the repository at this point in the history
  • Loading branch information
Chocobo1 committed Feb 19, 2025
1 parent e47f504 commit 19d0322
Showing 1 changed file with 4 additions and 5 deletions.
9 changes: 4 additions & 5 deletions .eleventy.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
import ChildProcess from "node:child_process";
import MarkdownItAnchor from "markdown-it-anchor";
import { promisify } from 'node:util';
import * as Fs from 'node:fs';
import * as FsPromises from 'node:fs/promises';
import * as Util from 'node:util';

export default (eleventyConfig) => {
const sourceDir = "src";
Expand Down Expand Up @@ -33,7 +34,7 @@ export default (eleventyConfig) => {
// Run after the build ends
eleventyConfig.on("eleventy.after", async ({ dir }) => {
const run = (cmd) => {
const exec = promisify(ChildProcess.exec);
const exec = Util.promisify(ChildProcess.exec);
return exec(cmd).then(
(result) => { console.log(result.stdout); },
(result) => { console.error(result.stderr); }
Expand All @@ -51,13 +52,11 @@ export default (eleventyConfig) => {
const targets = [
[`${sourceDir}/news.md`, `${dir.output}/news.html`]
];
const utimes = promisify(Fs.utimes);

const promises = targets.map((target) => {
const src = target[0];
const dest = target[1];
const srcStat = Fs.statSync(src);
return utimes(dest, srcStat.atime, srcStat.mtime);
return FsPromises.utimes(dest, srcStat.atime, srcStat.mtime);
});
return Promise.allSettled(promises);
};
Expand Down

0 comments on commit 19d0322

Please sign in to comment.