From 7f0b6a49db2c16c088bb7be0c29fdf4601982cd3 Mon Sep 17 00:00:00 2001 From: Pavel Kukushkin Date: Sun, 21 Mar 2021 22:54:09 +0300 Subject: [PATCH] Fix issue #236. Additional option "hiddenTerminal" --- index.js | 10 ++++++++-- readme.md | 7 +++++++ 2 files changed, 15 insertions(+), 2 deletions(-) diff --git a/index.js b/index.js index 3e43373..9122fe0 100644 --- a/index.js +++ b/index.js @@ -77,6 +77,7 @@ const open = async (target, options) => { options = { wait: false, background: false, + hiddenTerminal: false, allowNonzeroExitCode: false, ...options }; @@ -125,13 +126,18 @@ const open = async (target, options) => { `${mountPoint}c/Windows/System32/WindowsPowerShell/v1.0/powershell.exe` : `${process.env.SYSTEMROOT}\\System32\\WindowsPowerShell\\v1.0\\powershell`; + if (options.hiddenTerminal) { + cliArguments.push( + '–WindowStyle', + 'Hidden', + ); + } + cliArguments.push( '-NoProfile', '-NonInteractive', '–ExecutionPolicy', 'Bypass', - '–WindowStyle', - 'Hidden', '-EncodedCommand' ); diff --git a/readme.md b/readme.md index fe63779..7da0bfd 100644 --- a/readme.md +++ b/readme.md @@ -80,6 +80,13 @@ Default: `false` Do not bring the app to the foreground. +##### hiddenTerminal (Windows only) + +Type: `boolean`\ +Default: `false` + +Hide PowerShell terminal. If your node script is called from some gui application (from pkg-bundled app, from nodegui, etc.), than addition PowerShell window would be spawned. With this option `true` this window will be hidden. + ##### app Type: `{name: string | string[], arguments?: string[]} | Array<{name: string | string[], arguments: string[]}>`