Makes post-scripts run synchronously
This commit is contained in:
parent
991560fae1
commit
cdd1ac6090
2 changed files with 15 additions and 20 deletions
|
@ -1,5 +0,0 @@
|
||||||
#!/usr/bin/env bash
|
|
||||||
|
|
||||||
if command -v brew > /dev/null; then
|
|
||||||
brew info --json=v1 --installed
|
|
||||||
fi
|
|
|
@ -44,9 +44,9 @@ async function runScript(key, script) {
|
||||||
runSilentCommand(`glow --width 80 "${cacheDir}/${key}-glow"`)
|
runSilentCommand(`glow --width 80 "${cacheDir}/${key}-glow"`)
|
||||||
// TODO: Set process.env.DEBUG || true here because the asynchronous method is not logging properly / running slow
|
// TODO: Set process.env.DEBUG || true here because the asynchronous method is not logging properly / running slow
|
||||||
if (process.env.DEBUG) {
|
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 {
|
} 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) {
|
} catch (e) {
|
||||||
console.error(`Failed to run script associated with ${key}`, e)
|
console.error(`Failed to run script associated with ${key}`, e)
|
||||||
|
@ -571,22 +571,22 @@ async function main() {
|
||||||
})
|
})
|
||||||
await Promise.allSettled(usersGroupsAdditions)
|
await Promise.allSettled(usersGroupsAdditions)
|
||||||
log(`Running post-install inline scripts`)
|
log(`Running post-install inline scripts`)
|
||||||
const postScripts = installData
|
for (const x of installData) {
|
||||||
.flatMap(x => {
|
|
||||||
const postField = getPkgData('_post', x, x.installType)
|
const postField = getPkgData('_post', x, x.installType)
|
||||||
if (!postField) return Promise.resolve()
|
if (postField) {
|
||||||
log(`Running post-install script for ${x.listKey}`)
|
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`)
|
log(`Running post-install scripts defined in ~/.local/bin/post-installx`)
|
||||||
const postScriptFiles = installData
|
for (const x of installData) {
|
||||||
.flatMap(x => {
|
|
||||||
const scriptPath = `${os.homedir()}/.local/bin/post-installx/post-${x.listKey}.sh`
|
const scriptPath = `${os.homedir()}/.local/bin/post-installx/post-${x.listKey}.sh`
|
||||||
const scriptExists = fs.existsSync(scriptPath)
|
const scriptExists = fs.existsSync(scriptPath)
|
||||||
if (!scriptExists) return Promise.resolve()
|
if (scriptExists) {
|
||||||
log(`Running post-install script defined in ${scriptPath}`)
|
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(postScripts)
|
||||||
//await Promise.allSettled(postScriptFiles)
|
//await Promise.allSettled(postScriptFiles)
|
||||||
log(`Starting services flagged with _serviceEnabled`)
|
log(`Starting services flagged with _serviceEnabled`)
|
||||||
|
|
Loading…
Reference in a new issue