Skip to content

Commit 29210ce

Browse files
authored
Merge pull request #1 from abbenoir/bugfix/fix-handler-with-dot
Fix handler with dot in path
2 parents 33295cd + 1810c50 commit 29210ce

File tree

2 files changed

+19
-1
lines changed

2 files changed

+19
-1
lines changed

src/executeFunctions.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ const createHandler = (location, fn) => {
1717
process.env = Object.assign({}, originalEnv, fn.environment);
1818

1919
const handler = requireWithoutCache(
20-
location + '/' + fn.handler.split('.')[0],
20+
location + '/' + fn.handler.substring(0, fn.handler.lastIndexOf('.')),
2121
require
2222
)[
2323
fn.handler

test/executeFunctions.test.js

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -47,3 +47,21 @@ test('should able to handle multiple functions', () => {
4747
expect(result3).toBe('resultC');
4848
});
4949
});
50+
51+
test('should able to handle any functions with a dot in path', () => {
52+
return executeFunctions('result', `${process.cwd()}/test`, [
53+
{
54+
handler: './handler.functionA'
55+
},
56+
{
57+
handler: './handler.functionB'
58+
},
59+
{
60+
handler: './handler.functionC'
61+
}
62+
]).then(([result1, result2, result3, result4]) => {
63+
expect(result1).toBe('resultA');
64+
expect(result2).toBe('resultB');
65+
expect(result3).toBe('resultC');
66+
});
67+
});

0 commit comments

Comments
 (0)