Fix console error messages

This commit is contained in:
Kurt Hutten
2021-09-09 18:36:11 +10:00
parent 5d128c6cbd
commit 2e2e7be633
5 changed files with 23 additions and 16 deletions

View File

@@ -23,7 +23,7 @@ export async function writeFiles(
return tempFile
}
export async function runCommand(command, timeout = 5000): Promise<string> {
export async function runCommand(command, timeout = 5000, shouldRejectStdErr = false): Promise<string> {
return new Promise((resolve, reject) => {
exec(command, (error, stdout, stderr) => {
if (error) {
@@ -35,6 +35,10 @@ export async function runCommand(command, timeout = 5000): Promise<string> {
}
if (stderr) {
console.log(`stderr: ${stderr}`)
if (shouldRejectStdErr) {
reject(stderr)
return
}
resolve(stderr)
return
}
@@ -105,7 +109,8 @@ export async function storeAssetAndReturnUrl({
if (error) {
const response = {
statusCode: 400,
body: JSON.stringify({ error, fullPath }),
body: Buffer.from(JSON.stringify({ error, fullPath })).toString('base64'),
isBase64Encoded: true,
}
callback(null, response)
return
@@ -119,7 +124,8 @@ export async function storeAssetAndReturnUrl({
console.log('read file error', e)
const response = {
statusCode: 400,
body: JSON.stringify({ error: consoleMessage, fullPath }),
body: Buffer.from(JSON.stringify({ error: consoleMessage, fullPath })).toString('base64'),
isBase64Encoded: true,
}
callback(null, response)
return