From cdd1ac6090ef5b94ac13c3a2b82c8e3f277fc2d3 Mon Sep 17 00:00:00 2001 From: Brian Zalewski <59970525+ProfessorManhattan@users.noreply.github.com> Date: Mon, 6 May 2024 03:34:59 +0000 Subject: [PATCH] Makes post-scripts run synchronously --- .../bin/executable_install-program-cache.tmpl | 5 ---- home/dot_local/bin/executable_installx | 30 +++++++++---------- 2 files changed, 15 insertions(+), 20 deletions(-) delete mode 100644 home/dot_local/bin/executable_install-program-cache.tmpl diff --git a/home/dot_local/bin/executable_install-program-cache.tmpl b/home/dot_local/bin/executable_install-program-cache.tmpl deleted file mode 100644 index 90117f09..00000000 --- a/home/dot_local/bin/executable_install-program-cache.tmpl +++ /dev/null @@ -1,5 +0,0 @@ -#!/usr/bin/env bash - -if command -v brew > /dev/null; then - brew info --json=v1 --installed -fi diff --git a/home/dot_local/bin/executable_installx b/home/dot_local/bin/executable_installx index f47e71ac..e0f62031 100644 --- a/home/dot_local/bin/executable_installx +++ b/home/dot_local/bin/executable_installx @@ -44,9 +44,9 @@ async function runScript(key, script) { runSilentCommand(`glow --width 80 "${cacheDir}/${key}-glow"`) // TODO: Set process.env.DEBUG || true here because the asynchronous method is not logging properly / running slow if (process.env.DEBUG) { - return runSilentCommand(`bash "${cacheDir}/${key}" || logg error 'Error occurred while processing script for ${key}'`) + return await runSilentCommand(`bash "${cacheDir}/${key}" || logg error 'Error occurred while processing script for ${key}'`) } else { - return $`bash "${cacheDir}/${key}" || logg error 'Error occurred while processing script for ${key}'`.pipe(process.stdout) + return await $`bash "${cacheDir}/${key}" || logg error 'Error occurred while processing script for ${key}'`.pipe(process.stdout) } } catch (e) { console.error(`Failed to run script associated with ${key}`, e) @@ -571,22 +571,22 @@ async function main() { }) await Promise.allSettled(usersGroupsAdditions) log(`Running post-install inline scripts`) - const postScripts = installData - .flatMap(x => { - const postField = getPkgData('_post', x, x.installType) - if (!postField) return Promise.resolve() + for (const x of installData) { + const postField = getPkgData('_post', x, x.installType) + if (postField) { log(`Running post-install script for ${x.listKey}`) - return (postField && runScript(x.listKey, x[postField])) || Promise.resolve() - }) + await runScript(x.listKey, x[postField]) + } + } log(`Running post-install scripts defined in ~/.local/bin/post-installx`) - const postScriptFiles = installData - .flatMap(x => { - const scriptPath = `${os.homedir()}/.local/bin/post-installx/post-${x.listKey}.sh` - const scriptExists = fs.existsSync(scriptPath) - if (!scriptExists) return Promise.resolve() + for (const x of installData) { + const scriptPath = `${os.homedir()}/.local/bin/post-installx/post-${x.listKey}.sh` + const scriptExists = fs.existsSync(scriptPath) + if (scriptExists) { log(`Running post-install script defined in ${scriptPath}`) - return runScript(`post-${x.listKey}.sh`, fs.readFileSync(scriptPath, 'utf8')) - }) + await runScript(`post-${x.listKey}.sh`, fs.readFileSync(scriptPath, 'utf8')) + } + } //await Promise.allSettled(postScripts) //await Promise.allSettled(postScriptFiles) log(`Starting services flagged with _serviceEnabled`)