From 833d1f336bd60825a9e401cf0364c6d1f6544e12 Mon Sep 17 00:00:00 2001 From: ali asaria <ali.asaria@gmail.com> Date: Wed, 6 Mar 2024 17:46:33 -0500 Subject: [PATCH] fix major script run issues with app by forcing scripts to run in bash --- src/main/util.ts | 14 +++++++++++--- 1 file changed, 11 insertions(+), 3 deletions(-) diff --git a/src/main/util.ts b/src/main/util.ts index b0f53370..08320840 100644 --- a/src/main/util.ts +++ b/src/main/util.ts @@ -7,6 +7,7 @@ const { spawn, exec, ChildProcess } = require('child_process'); const util = require('node:util'); const awaitExec = util.promisify(require('node:child_process').exec); const homeDir = os.homedir(); +const transformerLabRootDir = path.join(homeDir, '.transformerlab/'); const transformerLabDir = path.join(homeDir, '.transformerlab/src/'); const commandExistsSync = require('command-exists').sync; @@ -48,7 +49,7 @@ export function startLocalServer() { // The following two options allow it to keep running after parent is closed detached: true, stdio: ['ignore', out, err], - shell: true, + shell: '/bin/bash', }; console.log('Starting local server at', mainFile); localServer = spawn('bash', [mainFile], options); @@ -108,7 +109,11 @@ export function killLocalServer() { export function installLocalServer() { console.log('Installing local server'); - const options = { shell: '/bin/bash' }; + if (!fs.existsSync(transformerLabRootDir)) { + fs.mkdirSync(transformerLabRootDir); + } + + const options = { shell: '/bin/bash', cwd: transformerLabRootDir }; try { const child = exec( 'curl https://raw.githubusercontent.com/transformerlab/transformerlab-api/main/install.sh | bash', @@ -202,7 +207,10 @@ export async function executeInstallStep( argument: string, useLocalInstallSh = false ) { - const options = {}; + if (!fs.existsSync(transformerLabRootDir)) { + fs.mkdirSync(transformerLabRootDir); + } + const options = { cwd: transformerLabRootDir }; console.log('Running install.sh ' + argument); if (useLocalInstallSh) { -- GitLab