From a1d90e2020108d41ff1a8392488ac39029c0e7fc Mon Sep 17 00:00:00 2001 From: Stephen Donchez Date: Sat, 9 Jan 2021 19:36:13 -0500 Subject: [PATCH] Fixes required for windows functionality Windows can't handle TTY, so this checks the OS before setting the flag. Allows the user to configure the timeout, because 60 seconds is annoying if you're setting a lot of variables. Also allows parameters to be passed into the editor call, as Visual Studio Code, for example, requires a -w flag to block the terminal until the user is done editing. Co-Authored-By: andrewkurzweil <26608741+andrewkurzweil@users.noreply.github.com> --- config/credentials.php | 6 +++++- src/EditCredentialsCommand.php | 14 +++++++++++--- 2 files changed, 16 insertions(+), 4 deletions(-) diff --git a/config/credentials.php b/config/credentials.php index 368ac5b..9213ebb 100644 --- a/config/credentials.php +++ b/config/credentials.php @@ -15,6 +15,10 @@ 'cipher' => config('app.cipher'), - 'editor' => env('EDITOR', 'vi') + 'editor' => env('EDITOR', 'vi'), + + 'editorParams' => env('EDITOR_PARAMS'), + + 'timeout' => env('EDITOR_TIMEOUT', 60) ]; diff --git a/src/EditCredentialsCommand.php b/src/EditCredentialsCommand.php index efb7aad..6b92cbd 100644 --- a/src/EditCredentialsCommand.php +++ b/src/EditCredentialsCommand.php @@ -39,11 +39,19 @@ public function handle(Credentials $credentials) fwrite($handle, json_encode($decrypted, JSON_PRETTY_PRINT | JSON_FORCE_OBJECT)); - $editor = config('credential.editor', 'vi'); + $editor = config('credentials.editor', 'vi'); + $editorParams = config('credentials.editorParams'); - $process = new Process([$editor, $meta['uri']]); + $process = new Process([$editor, $editorParams, $meta['uri']], + null, + null, + null, + config('credentials.timeout')); - $process->setTty(true); + if (!(stripos(PHP_OS, 'WIN') === 0 || PHP_OS_FAMILY === "Windows")) + { + $process->setTty(true); + } $process->mustRun(); $data = json_decode(file_get_contents($meta['uri']), JSON_OBJECT_AS_ARRAY);