Skip to content

Commit

Permalink
Use recursive-copy on Windows
Browse files Browse the repository at this point in the history
  • Loading branch information
zachleat committed Dec 20, 2024
1 parent 3a06a19 commit 4a83c2b
Showing 1 changed file with 9 additions and 6 deletions.
15 changes: 9 additions & 6 deletions test/test.js
Original file line number Diff line number Diff line change
@@ -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");
Expand Down Expand Up @@ -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/",
Expand All @@ -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/",
Expand Down

0 comments on commit 4a83c2b

Please sign in to comment.