From bb47cf7df4b74e38a28b509b1fb492ceb2de6ab4 Mon Sep 17 00:00:00 2001 From: Enrico Stahn Date: Fri, 29 Jul 2022 00:50:24 +1000 Subject: [PATCH] fix: debug logs for command execution failure If docker command execution fails due to a bad `Dockerfile` the error will always be `docker not found`. This will allow to output the actual exception instead. --- lib/docker.js | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/lib/docker.js b/lib/docker.js index 68cf935b..e3dce577 100644 --- a/lib/docker.js +++ b/lib/docker.js @@ -10,10 +10,19 @@ const os = require('os'); * @return {Object} */ async function dockerCommand(options, pluginInstance) { + const { serverless, log } = pluginInstance; + const debug = process.env.SLS_DEBUG; const cmd = 'docker'; try { return await spawn(cmd, options, { encoding: 'utf-8' }); } catch (e) { + if (debug) { + if (log) { + log.debug(e); + } else { + serverless.cli.log(e); + } + } if ( e.stderrBuffer && e.stderrBuffer.toString().includes('command not found')