Skip to content

Commit cc67250

Browse files
fix #75: SAM - do not throw an error if file do not exists (#76)
1 parent e7dcabc commit cc67250

File tree

1 file changed

+11
-5
lines changed

1 file changed

+11
-5
lines changed

src/frameworks/samFramework.ts

Lines changed: 11 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -167,9 +167,11 @@ export class SamFramework implements IFramework {
167167

168168
if (!codePath) {
169169
const fileWithExtension = handlerParts[0];
170+
const possibleCodePathsTs = `${fileWithExtension}.ts`;
171+
const possibleCodePathsJs = `${fileWithExtension}.js`;
170172
const possibleCodePaths = [
171-
`${fileWithExtension}.ts`,
172-
`${fileWithExtension}.js`,
173+
possibleCodePathsTs,
174+
possibleCodePathsJs,
173175
`${fileWithExtension}.cjs`,
174176
`${fileWithExtension}.mjs`,
175177
];
@@ -183,10 +185,14 @@ export class SamFramework implements IFramework {
183185
// ignore, file not found
184186
}
185187
}
186-
}
187188

188-
if (!codePath) {
189-
throw new Error(`Code path not found for function: ${func.Name}`);
189+
if (!codePath) {
190+
codePath = possibleCodePathsJs;
191+
192+
Logger.warn(
193+
`[Function ${functionName}] Can not find code path for handler: ${handlerFull}. Using fallback: ${codePath}`,
194+
);
195+
}
190196
}
191197

192198
const packageJsonPath = await findPackageJson(codePath);

0 commit comments

Comments
 (0)