From 2916dcc58c46591c5ee3a4700c874f60d2be4c3f Mon Sep 17 00:00:00 2001 From: Cooldude2606 <25043174+Cooldude2606@users.noreply.github.com> Date: Tue, 23 Jan 2024 02:47:10 +0000 Subject: [PATCH] Fix hang from rl.close on windows --- packages/create/create.js | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/packages/create/create.js b/packages/create/create.js index 5d3432c2..599ffbd0 100755 --- a/packages/create/create.js +++ b/packages/create/create.js @@ -16,6 +16,18 @@ let dev = false; const scriptExt = process.platform === "win32" ? ".cmd" : ""; const finished = util.promisify(stream.finished); +// I hate this, there is a bug with rl.close on windows that was meant to have been fixed in Node14.4 +// See nodejs/node#21771 and nodejs/node#30701 for the apparent fix that was applied +// One option is to not call rl.close: SBoudrias/Inquirer.js#767 +// But this comes with its own issues: SBoudrias/Inquirer.js#899 +// The solution below was adapted from aws-amplify/amplify-cli#12347 +if (process.platform === "win32") { + const _inquirer_close = inquirer.ui.Prompt.prototype.close; + inquirer.ui.Prompt.prototype.close = function() { + this.rl.terminal = false; + _inquirer_close.call(this); + }; +} const availablePlugins = [ { name: "Global Chat", value: "@clusterio/plugin-global_chat" },