diff --git a/test/test.js b/test/test.js index 6a3ad74..a92e0ea 100644 --- a/test/test.js +++ b/test/test.js @@ -1,6 +1,7 @@ const path = require("node:path"); const fs = require("node:fs"); const { URL } = require("node:url"); +const copy = require("@11ty/recursive-copy"); const test = require("ava"); const sharp = require("sharp"); @@ -527,18 +528,20 @@ test("Keep a cache, don’t reuse with same file names and different options", a t.is(stats2.jpeg.length, 1); }); -function copyFile(src, dest) { - fs.copyFileSync(path.resolve(src), path.resolve(dest)); +async function copyFile(src, dest) { + return copy(src, dest, { + overwrite: true, + }); } test("Keep a cache, don’t reuse with if the image changes, check promise equality", async t => { - copyFile("./test/modify-bio-original.jpg", "./test/generated-modify-bio.jpg"); + await copyFile("./test/modify-bio-original.jpg", "./test/generated-modify-bio.jpg"); let promise1 = eleventyImage("./test/generated-modify-bio.jpg", { outputDir: "./test/img/", }); - copyFile("./test/modify-bio-grayscale.jpg", "./test/generated-modify-bio.jpg"); + await copyFile("./test/modify-bio-grayscale.jpg", "./test/generated-modify-bio.jpg"); let promise2 = eleventyImage("./test/generated-modify-bio.jpg", { outputDir: "./test/img/", @@ -548,13 +551,13 @@ test("Keep a cache, don’t reuse with if the image changes, check promise equal }); test("Keep a cache, don’t reuse with if the image changes, check output", async t => { - copyFile("./test/modify2-bio-original.jpg", "./test/generated-modify2-bio.jpg"); + await copyFile("./test/modify2-bio-original.jpg", "./test/generated-modify2-bio.jpg"); let stats1 = await eleventyImage("./test/generated-modify2-bio.jpg", { outputDir: "./test/img/", }); - copyFile("./test/modify2-bio-grayscale.jpg", "./test/generated-modify2-bio.jpg"); + await copyFile("./test/modify2-bio-grayscale.jpg", "./test/generated-modify2-bio.jpg"); let stats2 = await eleventyImage("./test/generated-modify2-bio.jpg", { outputDir: "./test/img/",