diff --git a/index.js b/index.js index 33e6a3da..017d0459 100644 --- a/index.js +++ b/index.js @@ -108,13 +108,18 @@ class ServerlessPythonRequirements { } }; + const isFunctionRuntimePython = args => { + // If functionObj.runtime is undefined, python. + if (!args[1].functionObj || !args[1].functionObj.runtime) { + return true; + } + return args[1].functionObj.runtime.startsWith('python'); + }; + const before = () => { - if ( - arguments[1].functionObj && - arguments[1].functionObj.runtime && - !arguments[1].functionObj.runtime.startsWith('python') - ) + if (!isFunctionRuntimePython(arguments)) { return; + } return BbPromise.bind(this) .then(pipfileToRequirements) .then(addVendorHelper) @@ -123,12 +128,9 @@ class ServerlessPythonRequirements { }; const after = () => { - if ( - arguments[1].functionObj && - arguments[1].functionObj.runtime && - !arguments[1].functionObj.runtime.startsWith('python') - ) + if (!isFunctionRuntimePython(arguments)) { return; + } return BbPromise.bind(this) .then(removeVendorHelper) .then(() =>