From 6ad5e6ba6458822153efe3b8872992dd86f02888 Mon Sep 17 00:00:00 2001 From: Ellpeck Date: Thu, 14 Mar 2024 10:12:46 +0100 Subject: [PATCH] feat-fix: fix the repl being broken from [this situation](https://github.com/Code-Inspect/flowr/pull/718#discussion_r1519874332), good job us --- src/flowr.ts | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/src/flowr.ts b/src/flowr.ts index b179a0aac8..f15a4a1f11 100644 --- a/src/flowr.ts +++ b/src/flowr.ts @@ -5,6 +5,7 @@ * Otherwise, it will start a REPL that can call these scripts and return their results repeatedly. */ import { log, LogLevel } from './util/log' +import type { RShellOptions } from './r-bridge' import { RShell } from './r-bridge' import type { OptionDefinition } from 'command-line-usage' import commandLineUsage from 'command-line-usage' @@ -90,15 +91,18 @@ setConfigFile(undefined, options['config-file'] ?? defaultConfigFile, true) function retrieveShell(): RShell { // we keep an active shell session to allow other parse investigations :) - return new RShell({ + let opts: Partial = { revive: 'always', onRevive: (code, signal) => { const signalText = signal == null ? '' : ` and signal ${signal}` console.log(formatter.format(`R process exited with code ${code}${signalText}. Restarting...`, { color: Colors.Magenta, effect: ColorEffect.Foreground })) console.log(italic(`If you want to exit, press either Ctrl+C twice, or enter ${bold(':quit')}`)) - }, - pathToRExecutable: options['r-path'] - }) + } + } + if(options['r-path']) { + opts = { ...opts, pathToRExecutable: options['r-path'] } + } + return new RShell(opts) } async function mainRepl() {