Skip to content

Commit

Permalink
Restore previous Windows code
Browse files Browse the repository at this point in the history
  • Loading branch information
zachleat committed Dec 19, 2024
1 parent 2438a79 commit f851100
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 6 deletions.
4 changes: 2 additions & 2 deletions src/global-options.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
const path = require("node:path");
// const os = require("node:os");
const os = require("node:os");

const Util = require("./util.js");
const svgHook = require("./format-hooks/svg.js");
Expand All @@ -9,7 +9,7 @@ const DEFAULTS = {
formats: ["webp", "jpeg"], // "png", "svg", "avif"

// Via https://github.com/11ty/eleventy-img/issues/258
concurrency: 16, //Math.min(Math.max(8, os.availableParallelism()), 16),
concurrency: Math.min(Math.max(8, os.availableParallelism()), 16),

urlPath: "/img/",
outputDir: "img/",
Expand Down
12 changes: 8 additions & 4 deletions test/test.js
Original file line number Diff line number Diff line change
Expand Up @@ -527,14 +527,18 @@ 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.normalize(src), path.normalize(dest));
}

test("Keep a cache, don’t reuse with if the image changes, check promise equality", async t => {
fs.copyFileSync("./test/modify-bio-original.jpg", "./test/generated-modify-bio.jpg");
copyFile("./test/modify-bio-original.jpg", "./test/generated-modify-bio.jpg");

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

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

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

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

fs.copyFileSync("./test/modify2-bio-grayscale.jpg", "./test/generated-modify2-bio.jpg");
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 f851100

Please sign in to comment.