From c212acd90baf412feb9c442c22cd93cfb60c9bf0 Mon Sep 17 00:00:00 2001 From: coderaiser Date: Mon, 27 May 2019 12:35:42 +0300 Subject: [PATCH] fix(terminal-run) resolve before close --- client/load-module.js | 2 +- client/modules/terminal-run.js | 37 ++++++++++++++++++---------------- 2 files changed, 21 insertions(+), 18 deletions(-) diff --git a/client/load-module.js b/client/load-module.js index 9c203e87..17afdef7 100644 --- a/client/load-module.js +++ b/client/load-module.js @@ -54,7 +54,7 @@ module.exports = function loadModule(params) { if (e) return console.error(e); - a.show(...args); + await a.show(...args); }; }; diff --git a/client/modules/terminal-run.js b/client/modules/terminal-run.js index 02ce4f28..01cadf38 100644 --- a/client/modules/terminal-run.js +++ b/client/modules/terminal-run.js @@ -53,7 +53,26 @@ module.exports.init = async () => { await loadAll(); }; -module.exports.show = show; +module.exports.show = promisify((options = {}, fn) => { + if (!Loaded) + return; + + if (!config('terminal')) + return; + + create(options); + + CloudCmd.View.show(Terminal.element, { + afterShow: () => { + Terminal.focus(); + }, + afterClose: (/* exec.series args */) => { + fn(); + }, + }); +}); + + module.exports.hide = hide; function hide () { @@ -128,19 +147,3 @@ function authCheck(spawn) { }); } -async function show(options = {}) { - if (!Loaded) - return; - - if (!config('terminal')) - return; - - await create(options); - - CloudCmd.View.show(Terminal.element, { - afterShow: () => { - Terminal.focus(); - }, - }); -} -