Skip to content

Commit

Permalink
Unlink directly
Browse files Browse the repository at this point in the history
  • Loading branch information
zachleat committed Dec 20, 2024
1 parent ca53718 commit 3464472
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 12 deletions.
1 change: 0 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,6 @@
"devDependencies": {
"@11ty/eleventy": "^3.0.0",
"@11ty/eleventy-plugin-webc": "^0.11.2",
"@11ty/recursive-copy": "^3.0.1",
"@eslint/eslintrc": "^3.2.0",
"@eslint/js": "^9.17.0",
"ava": "^6.2.0",
Expand Down
17 changes: 6 additions & 11 deletions test/test.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
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 @@ -528,20 +527,15 @@ test("Keep a cache, don’t reuse with same file names and different options", a
t.is(stats2.jpeg.length, 1);
});

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 => {
await copyFile("./test/modify-bio-original.jpg", "./test/generated-modify-bio.jpg");
fs.copyFileSync("./test/modify-bio-original.jpg", "./test/generated-modify-bio.jpg");

let promise1 = eleventyImage("./test/generated-modify-bio.jpg", {
outputDir: "./test/img/",
});

await copyFile("./test/modify-bio-grayscale.jpg", "./test/generated-modify-bio.jpg");
fs.unlinkSync("./test/generated-modify-bio.jpg");
fs.copyFileSync("./test/modify-bio-grayscale.jpg", "./test/generated-modify-bio.jpg");

let promise2 = eleventyImage("./test/generated-modify-bio.jpg", {
outputDir: "./test/img/",
Expand All @@ -551,13 +545,14 @@ 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 => {
await copyFile("./test/modify2-bio-original.jpg", "./test/generated-modify2-bio.jpg");
fs.copyFileSync("./test/modify2-bio-original.jpg", "./test/generated-modify2-bio.jpg");

let stats1 = await eleventyImage("./test/generated-modify2-bio.jpg", {
outputDir: "./test/img/",
});

await copyFile("./test/modify2-bio-grayscale.jpg", "./test/generated-modify2-bio.jpg");
fs.unlinkSync("./test/generated-modify-bio.jpg");
fs.copyFileSync("./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 3464472

Please sign in to comment.