Skip to content

Commit c4901fe

Browse files
abetomodschep
authored andcommitted
Improve function runtime check (#202)
- Add function to check functionObj.runtime - Add brace to if statement
1 parent d88b0fc commit c4901fe

File tree

1 file changed

+12
-10
lines changed

1 file changed

+12
-10
lines changed

index.js

+12-10
Original file line numberDiff line numberDiff line change
@@ -109,13 +109,18 @@ class ServerlessPythonRequirements {
109109
}
110110
};
111111

112+
const isFunctionRuntimePython = args => {
113+
// If functionObj.runtime is undefined, python.
114+
if (!args[1].functionObj || !args[1].functionObj.runtime) {
115+
return true;
116+
}
117+
return args[1].functionObj.runtime.startsWith('python');
118+
};
119+
112120
const before = () => {
113-
if (
114-
arguments[1].functionObj &&
115-
arguments[1].functionObj.runtime &&
116-
!arguments[1].functionObj.runtime.startsWith('python')
117-
)
121+
if (!isFunctionRuntimePython(arguments)) {
118122
return;
123+
}
119124
return BbPromise.bind(this)
120125
.then(pipfileToRequirements)
121126
.then(addVendorHelper)
@@ -124,12 +129,9 @@ class ServerlessPythonRequirements {
124129
};
125130

126131
const after = () => {
127-
if (
128-
arguments[1].functionObj &&
129-
arguments[1].functionObj.runtime &&
130-
!arguments[1].functionObj.runtime.startsWith('python')
131-
)
132+
if (!isFunctionRuntimePython(arguments)) {
132133
return;
134+
}
133135
return BbPromise.bind(this)
134136
.then(removeVendorHelper)
135137
.then(() =>

0 commit comments

Comments
 (0)