mirror of
https://github.com/zen-browser/pdf.js.git
synced 2025-07-08 17:30:09 +02:00
Drop custom confirmation logic in favor of using the built-in Node.js readline
module
Most likely this code predates our use of Node.js, but in Node.js asking for user confirmation is a solved problem, so we can remove the custom logic we have for this, which overall makes things much simpler.
This commit is contained in:
parent
869b396011
commit
a24982a733
2 changed files with 13 additions and 83 deletions
19
test/test.js
19
test/test.js
|
@ -25,6 +25,7 @@ var puppeteer = require("puppeteer");
|
|||
var url = require("url");
|
||||
var testUtils = require("./testutils.js");
|
||||
const dns = require("dns");
|
||||
const readline = require("readline");
|
||||
const yargs = require("yargs");
|
||||
|
||||
// Chrome uses host `127.0.0.1` in the browser's websocket endpoint URL while
|
||||
|
@ -229,14 +230,17 @@ function updateRefImages() {
|
|||
sync(false); // don't remove tmp/ for botio
|
||||
return;
|
||||
}
|
||||
testUtils.confirm(
|
||||
|
||||
const reader = readline.createInterface(process.stdin, process.stdout);
|
||||
reader.question(
|
||||
"Would you like to update the master copy in ref/? [yn] ",
|
||||
function (confirmed) {
|
||||
if (confirmed) {
|
||||
function (answer) {
|
||||
if (answer.toLowerCase() === "y") {
|
||||
sync(true);
|
||||
} else {
|
||||
console.log(" OK, not updating.");
|
||||
}
|
||||
reader.close();
|
||||
}
|
||||
);
|
||||
}
|
||||
|
@ -358,13 +362,16 @@ function startRefTest(masterMode, showRefImages) {
|
|||
}
|
||||
console.log("Temporary snapshot dir tmp/ is still around.");
|
||||
console.log("tmp/ can be removed if it has nothing you need.");
|
||||
testUtils.confirm(
|
||||
|
||||
const reader = readline.createInterface(process.stdin, process.stdout);
|
||||
reader.question(
|
||||
"SHOULD THIS SCRIPT REMOVE tmp/? THINK CAREFULLY [yn] ",
|
||||
function (confirmed) {
|
||||
if (confirmed) {
|
||||
function (answer) {
|
||||
if (answer.toLowerCase() === "y") {
|
||||
testUtils.removeDirSync(refsTmpDir);
|
||||
}
|
||||
setup();
|
||||
reader.close();
|
||||
}
|
||||
);
|
||||
} else {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue