mirror of
https://github.com/Smaug123/KaTeX
synced 2025-10-07 04:08:43 +00:00
Fix screenshotter race conditions (#1643)
* Fix screenshotter race conditions * Update screenshotter.js * Update screenshotter.js
This commit is contained in:
@@ -475,10 +475,13 @@ function takeScreenshot(key) {
|
|||||||
const bufFile = path.join(outputDir, filenamePrefix + ".png");
|
const bufFile = path.join(outputDir, filenamePrefix + ".png");
|
||||||
|
|
||||||
let promise = fs.ensureDir(outputDir)
|
let promise = fs.ensureDir(outputDir)
|
||||||
.then(fs.writeFile(bufFile, buf));
|
.then(function() {
|
||||||
|
return fs.writeFile(bufFile, buf);
|
||||||
|
});
|
||||||
if (opts.diff) {
|
if (opts.diff) {
|
||||||
promise = promise.then(fs.ensureDir(diffDir))
|
promise = promise.then(fs.ensureDir(diffDir))
|
||||||
.then(execFile("convert", [
|
.then(function() {
|
||||||
|
return execFile("convert", [
|
||||||
"-fill", "white",
|
"-fill", "white",
|
||||||
// First image: saved screenshot in red
|
// First image: saved screenshot in red
|
||||||
"(", baseFile, "-colorize", "100,0,0", ")",
|
"(", baseFile, "-colorize", "100,0,0", ")",
|
||||||
@@ -486,13 +489,16 @@ function takeScreenshot(key) {
|
|||||||
"(", bufFile, "-colorize", "0,80,0", ")",
|
"(", bufFile, "-colorize", "0,80,0", ")",
|
||||||
// Composite them
|
// Composite them
|
||||||
"-compose", "darken", "-composite",
|
"-compose", "darken", "-composite",
|
||||||
"-trim", // remove everything with the same color as the
|
"-trim", // remove everything with the same color as
|
||||||
// corners
|
// the corners
|
||||||
diffFile, // output file name
|
diffFile, // output file name
|
||||||
]));
|
]);
|
||||||
|
});
|
||||||
}
|
}
|
||||||
if (!opts.new) {
|
if (!opts.new) {
|
||||||
promise = promise.then(fs.unlink(bufFile));
|
promise = promise.then(function() {
|
||||||
|
return fs.unlink(bufFile);
|
||||||
|
});
|
||||||
}
|
}
|
||||||
return promise;
|
return promise;
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user