@swydo/byol 2.1.0 → 2.1.3

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/CHANGELOG.md CHANGED
@@ -3,12 +3,283 @@
3
3
  All notable changes to this project will be documented in this file.
4
4
  See [Conventional Commits](https://conventionalcommits.org) for commit guidelines.
5
5
 
6
- # 2.1.0 (2021-09-07)
6
+ ## 2.1.3 (2022-04-25)
7
+
8
+ **Note:** Version bump only for package @swydo/byol
9
+
10
+
11
+
12
+
13
+
14
+ ## 2.1.2 (2022-04-25)
15
+
16
+ **Note:** Version bump only for package @swydo/byol
17
+
18
+
19
+
20
+
21
+
22
+ ## 2.1.1 (2022-04-25)
23
+
24
+ **Note:** Version bump only for package @swydo/byol
25
+
26
+
27
+
28
+
29
+
30
+ # 2.1.0 (2022-04-22)
7
31
 
8
32
 
9
33
  ### Features
10
34
 
11
- * **byol-cli:** add API Gateway v2 "http" request context param ([#274](https://github.com/Swydo/byol/issues/274)) ([c33e741](https://github.com/Swydo/byol/commit/c33e741296da242faaeaf9d9d0cb3ed8edc4b8de))
35
+ * support `--inspect` to enable attaching a debugger to child processes ([#376](https://github.com/Swydo/byol/issues/376)) ([097d139](https://github.com/Swydo/byol/commit/097d139f1690b64a3a994cd2c4fa44be7a61e49d))
36
+
37
+
38
+
39
+
40
+
41
+ ## 2.0.36 (2022-04-22)
42
+
43
+ **Note:** Version bump only for package @swydo/byol
44
+
45
+
46
+
47
+
48
+
49
+ ## 2.0.35 (2022-04-22)
50
+
51
+ **Note:** Version bump only for package @swydo/byol
52
+
53
+
54
+
55
+
56
+
57
+ ## 2.0.34 (2022-04-22)
58
+
59
+ **Note:** Version bump only for package @swydo/byol
60
+
61
+
62
+
63
+
64
+
65
+ ## 2.0.33 (2022-04-22)
66
+
67
+
68
+ ### Bug Fixes
69
+
70
+ * **deps:** revert dateformat to 4.y.z ([#373](https://github.com/Swydo/byol/issues/373)) ([6ea71d2](https://github.com/Swydo/byol/commit/6ea71d271bf861fe268cb7e370b26d3d8a3dbd73))
71
+
72
+
73
+
74
+
75
+
76
+ ## 2.0.32 (2022-04-06)
77
+
78
+ **Note:** Version bump only for package @swydo/byol
79
+
80
+
81
+
82
+
83
+
84
+ ## 2.0.31 (2022-04-06)
85
+
86
+ **Note:** Version bump only for package @swydo/byol
87
+
88
+
89
+
90
+
91
+
92
+ ## 2.0.30 (2022-04-06)
93
+
94
+ **Note:** Version bump only for package @swydo/byol
95
+
96
+
97
+
98
+
99
+
100
+ ## 2.0.29 (2022-04-06)
101
+
102
+ **Note:** Version bump only for package @swydo/byol
103
+
104
+
105
+
106
+
107
+
108
+ ## 2.0.28 (2022-04-06)
109
+
110
+ **Note:** Version bump only for package @swydo/byol
111
+
112
+
113
+
114
+
115
+
116
+ ## 2.0.27 (2022-04-06)
117
+
118
+ **Note:** Version bump only for package @swydo/byol
119
+
120
+
121
+
122
+
123
+
124
+ ## 2.0.26 (2022-04-06)
125
+
126
+ **Note:** Version bump only for package @swydo/byol
127
+
128
+
129
+
130
+
131
+
132
+ ## 2.0.25 (2022-04-06)
133
+
134
+ **Note:** Version bump only for package @swydo/byol
135
+
136
+
137
+
138
+
139
+
140
+ ## 2.0.24 (2022-04-06)
141
+
142
+ **Note:** Version bump only for package @swydo/byol
143
+
144
+
145
+
146
+
147
+
148
+ ## 2.0.23 (2022-04-06)
149
+
150
+ **Note:** Version bump only for package @swydo/byol
151
+
152
+
153
+
154
+
155
+
156
+ ## 2.0.22 (2022-04-06)
157
+
158
+ **Note:** Version bump only for package @swydo/byol
159
+
160
+
161
+
162
+
163
+
164
+ ## 2.0.21 (2022-04-06)
165
+
166
+ **Note:** Version bump only for package @swydo/byol
167
+
168
+
169
+
170
+
171
+
172
+ ## 2.0.20 (2022-04-06)
173
+
174
+ **Note:** Version bump only for package @swydo/byol
175
+
176
+
177
+
178
+
179
+
180
+ ## 2.0.19 (2022-04-06)
181
+
182
+ **Note:** Version bump only for package @swydo/byol
183
+
184
+
185
+
186
+
187
+
188
+ ## 2.0.18 (2022-04-06)
189
+
190
+ **Note:** Version bump only for package @swydo/byol
191
+
192
+
193
+
194
+
195
+
196
+ ## 2.0.17 (2022-04-06)
197
+
198
+ **Note:** Version bump only for package @swydo/byol
199
+
200
+
201
+
202
+
203
+
204
+ ## 2.0.16 (2022-04-06)
205
+
206
+ **Note:** Version bump only for package @swydo/byol
207
+
208
+
209
+
210
+
211
+
212
+ ## 2.0.15 (2022-04-06)
213
+
214
+
215
+ ### Bug Fixes
216
+
217
+ * **byol:** fix cwd not being set to CodeUri from CloudFormation file ([#363](https://github.com/Swydo/byol/issues/363)) ([8c6ce63](https://github.com/Swydo/byol/commit/8c6ce631e5c47ecfcbd3b1c5548cc8f2fcb51805))
218
+
219
+
220
+
221
+
222
+
223
+ ## 2.0.14 (2022-04-04)
224
+
225
+
226
+ ### Bug Fixes
227
+
228
+ * **byol:** add timeout delay to print all the logs ([#356](https://github.com/Swydo/byol/issues/356)) ([937393b](https://github.com/Swydo/byol/commit/937393bed0bd8c88e4776619d27f954e7077cc71))
229
+
230
+
231
+
232
+
233
+
234
+ ## 2.0.13 (2021-10-25)
235
+
236
+ **Note:** Version bump only for package @swydo/byol
237
+
238
+
239
+
240
+
241
+
242
+ ## 2.0.12 (2021-10-13)
243
+
244
+ **Note:** Version bump only for package @swydo/byol
245
+
246
+
247
+
248
+
249
+
250
+ ## 2.0.11 (2021-10-13)
251
+
252
+ **Note:** Version bump only for package @swydo/byol
253
+
254
+
255
+
256
+
257
+
258
+ ## 2.0.10 (2021-09-15)
259
+
260
+
261
+ ### Bug Fixes
262
+
263
+ * **byol-cli:** Mismatch between amazon and local api ([#278](https://github.com/Swydo/byol/issues/278)) ([1e40d93](https://github.com/Swydo/byol/commit/1e40d93178203389f9bcfa742b923023f64d0944))
264
+
265
+
266
+
267
+
268
+
269
+ ## 2.0.9 (2021-09-10)
270
+
271
+
272
+ ### Bug Fixes
273
+
274
+ * **byol-cli:** do not stringify body of lambda result ([#275](https://github.com/Swydo/byol/issues/275)) ([38ebcef](https://github.com/Swydo/byol/commit/38ebcefca31e100ada02425771b9dda9600a320f))
275
+
276
+
277
+
278
+
279
+
280
+ ## 2.0.8 (2021-09-07)
281
+
282
+ **Note:** Version bump only for package @swydo/byol
12
283
 
13
284
 
14
285
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@swydo/byol",
3
- "version": "2.1.0",
3
+ "version": "2.1.3",
4
4
  "description": "Bring Your Own Lambda",
5
5
  "license": "MIT",
6
6
  "engines": {
@@ -22,10 +22,10 @@
22
22
  "yaml-cfn": "^0.3.1"
23
23
  },
24
24
  "devDependencies": {
25
- "aws-xray-sdk-core": "3.3.3"
25
+ "aws-xray-sdk-core": "3.3.5"
26
26
  },
27
27
  "peerDependencies": {
28
28
  "aws-xray-sdk-core": "^3.0.0"
29
29
  },
30
- "gitHead": "c33e741296da242faaeaf9d9d0cb3ed8edc4b8de"
30
+ "gitHead": "8b592173687864c4f6945dbef948e84012f63a02"
31
31
  }
@@ -1,3 +1,4 @@
1
+ const path = require('path');
1
2
  const workerpool = require('workerpool');
2
3
  const { generateRequestId } = require('../generateRequestId');
3
4
 
@@ -17,7 +18,7 @@ function hasXRay() {
17
18
  }
18
19
 
19
20
  async function execute(handler, event, awsContext) {
20
- return new Promise(((resolve, reject) => {
21
+ const handlerResult = await new Promise(((resolve, reject) => {
21
22
  const maybePromise = handler(event, awsContext, (err, res) => {
22
23
  if (err) {
23
24
  reject(err);
@@ -36,6 +37,12 @@ async function execute(handler, event, awsContext) {
36
37
  .catch((err) => reject(err));
37
38
  }
38
39
  }));
40
+
41
+ // Timeout delay is required in order to print console logs
42
+ // that are omitted otherwise
43
+ await new Promise((resolve) => setTimeout(resolve, 10));
44
+
45
+ return handlerResult;
39
46
  }
40
47
 
41
48
  async function executeWithXRay(segmentName, handler, event, awsContext) {
@@ -61,13 +68,15 @@ async function executeWithXRay(segmentName, handler, event, awsContext) {
61
68
  }
62
69
 
63
70
  async function callHandler({
64
- absoluteIndexPath,
71
+ indexPath,
65
72
  handlerName,
66
73
  event,
67
74
  environment,
68
75
  }) {
69
76
  process.env = environment;
70
77
 
78
+ const absoluteIndexPath = path.join(process.cwd(), indexPath);
79
+
71
80
  const { [handlerName]: handler } = await import(absoluteIndexPath);
72
81
  const awsContext = {
73
82
  awsRequestId: generateRequestId(),
@@ -3,16 +3,16 @@ const workerpool = require('workerpool');
3
3
 
4
4
  const workerPoolMap = new Map();
5
5
 
6
- function getWorkerPoolKey(absoluteIndexPath, handlerName, requestId) {
6
+ function getWorkerPoolKey(indexPath, handlerName, requestId, poolOptions) {
7
7
  if (requestId) {
8
- return `${absoluteIndexPath}:${handlerName}:${requestId}`;
8
+ return `${indexPath}:${handlerName}:${requestId}:${JSON.stringify(poolOptions)}`;
9
9
  }
10
10
 
11
- return `${absoluteIndexPath}:${handlerName}`;
11
+ return `${indexPath}:${handlerName}:${JSON.stringify(poolOptions)}`;
12
12
  }
13
13
 
14
- function terminateWorkerPool(absoluteIndexPath, handlerName, requestId) {
15
- const poolKey = getWorkerPoolKey(absoluteIndexPath, handlerName, requestId);
14
+ function terminateWorkerPool(indexPath, handlerName, requestId, poolOptions) {
15
+ const poolKey = getWorkerPoolKey(indexPath, handlerName, requestId, poolOptions);
16
16
 
17
17
  const { pool } = workerPoolMap.get(poolKey);
18
18
  const terminationPromise = pool.terminate();
@@ -26,25 +26,34 @@ function terminateWorkerPools() {
26
26
  const terminationPromises = [];
27
27
 
28
28
  workerPoolMap.forEach((pool) => {
29
- const { absoluteIndexPath, handlerName, requestId } = pool;
30
- terminationPromises.push(terminateWorkerPool(absoluteIndexPath, handlerName, requestId));
29
+ const {
30
+ absoluteIndexPath,
31
+ handlerName,
32
+ requestId,
33
+ poolOptions,
34
+ } = pool;
35
+ terminationPromises.push(terminateWorkerPool(absoluteIndexPath, handlerName, requestId, poolOptions));
31
36
  });
32
37
 
33
38
  return Promise.all(terminationPromises);
34
39
  }
35
40
 
36
- async function getWorkerPool(absoluteIndexPath, handlerName, environment = {}, requestId) {
37
- const poolKey = getWorkerPoolKey(absoluteIndexPath, handlerName, requestId);
41
+ async function getWorkerPool(indexPath, handlerName, environment = {}, requestId, poolOptions = {}) {
42
+ const poolKey = getWorkerPoolKey(indexPath, handlerName, requestId, poolOptions);
38
43
 
39
44
  if (!workerPoolMap.has(poolKey)) {
40
- const pool = workerpool.pool(path.join(__dirname, 'assets', 'callHandlerProcess.js'));
45
+ const pool = workerpool.pool(path.join(__dirname, 'assets', 'callHandlerProcess.js'), {
46
+ workerType: 'process',
47
+ ...poolOptions,
48
+ });
41
49
 
42
50
  workerPoolMap.set(poolKey, {
43
51
  pool,
44
- absoluteIndexPath,
52
+ indexPath,
45
53
  handlerName,
46
54
  environment,
47
55
  requestId,
56
+ poolOptions,
48
57
  });
49
58
  }
50
59
 
@@ -53,7 +62,7 @@ async function getWorkerPool(absoluteIndexPath, handlerName, environment = {}, r
53
62
  if (JSON.stringify(poolEnvironment) !== JSON.stringify(environment)) {
54
63
  terminateWorkerPool(poolKey);
55
64
 
56
- return getWorkerPool(absoluteIndexPath, handlerName, environment);
65
+ return getWorkerPool(indexPath, handlerName, environment, requestId, poolOptions);
57
66
  }
58
67
 
59
68
  return pool;
@@ -41,10 +41,12 @@ function getAwsEnvironment({ profile, region }) {
41
41
  async function invokeFunction(functionName, event, {
42
42
  templatePath = path.join(process.cwd(), 'template.yml'),
43
43
  envPath = path.join(process.cwd(), 'env.json'),
44
+ debugPortStart,
44
45
  region,
45
46
  requestId,
46
47
  keepAlive = false,
47
48
  profile = 'default',
49
+ invocationType = 'RequestResponse',
48
50
  } = {}) {
49
51
  const resource = getFunctionResource(templatePath, functionName);
50
52
  const environment = {
@@ -55,36 +57,33 @@ async function invokeFunction(functionName, event, {
55
57
  Properties: {
56
58
  Handler: handler,
57
59
  CodeUri: codeUri = '.',
58
- EventInvokeConfig: eventInvokeConfig,
59
60
  },
60
61
  } = resource;
61
62
 
62
63
  const [relativePathWithoutExtension, handlerName] = handler.split('.');
63
64
 
64
- const relativeIndexPath = `${relativePathWithoutExtension}.js`;
65
- const absoluteIndexPath = path.join(templatePath, '..', codeUri, relativeIndexPath);
65
+ const workingDirectory = path.join(templatePath, '..', codeUri);
66
+ const indexPath = `${relativePathWithoutExtension}.js`;
66
67
 
67
68
  const options = {
68
- absoluteIndexPath,
69
+ indexPath,
70
+ debugPortStart,
69
71
  handlerName,
70
72
  environment,
71
73
  event,
72
74
  keepAlive,
73
75
  requestId,
76
+ workingDirectory,
74
77
  };
75
78
 
76
79
  let result;
77
- let invocationType;
78
-
79
- if (eventInvokeConfig) {
80
+ if (invocationType === 'Event') {
80
81
  invokeHandler(options);
81
- invocationType = 'Event';
82
82
  } else {
83
83
  result = await invokeHandler(options);
84
- invocationType = 'RequestResponse';
85
84
  }
86
85
 
87
- return { result, invocationType };
86
+ return { result };
88
87
  }
89
88
 
90
89
  module.exports = {
@@ -28,7 +28,7 @@ describe('invokeFunction', function () {
28
28
  foo: 'foo',
29
29
  };
30
30
 
31
- const { result, invocationType } = await invokeFunction(
31
+ const { result } = await invokeFunction(
32
32
  'GoodFunction',
33
33
  event,
34
34
  { templatePath },
@@ -37,7 +37,6 @@ describe('invokeFunction', function () {
37
37
  expect(result).to.be.an('object');
38
38
  expect(result).to.have.property('env');
39
39
  expect(result).to.have.property('args');
40
- expect(invocationType).to.equal('RequestResponse');
41
40
  });
42
41
 
43
42
  it('invokes the non-async function\'s handler', async function () {
@@ -46,7 +45,7 @@ describe('invokeFunction', function () {
46
45
  foo: 'foo',
47
46
  };
48
47
 
49
- const { result, invocationType } = await invokeFunction(
48
+ const { result } = await invokeFunction(
50
49
  'GoodCallbackFunction',
51
50
  event,
52
51
  { templatePath },
@@ -55,7 +54,6 @@ describe('invokeFunction', function () {
55
54
  expect(result).to.be.an('object');
56
55
  expect(result).to.have.property('env');
57
56
  expect(result).to.have.property('args');
58
- expect(invocationType).to.equal('RequestResponse');
59
57
  });
60
58
 
61
59
  it('invokes the function\'s handler with the given event', async function () {
@@ -64,7 +62,7 @@ describe('invokeFunction', function () {
64
62
  foo: 'foo',
65
63
  };
66
64
 
67
- const { result, invocationType } = await invokeFunction(
65
+ const { result } = await invokeFunction(
68
66
  'GoodFunction',
69
67
  event,
70
68
  { templatePath },
@@ -73,7 +71,6 @@ describe('invokeFunction', function () {
73
71
  expect(result).to.be.an('object');
74
72
  expect(result).to.have.property('env');
75
73
  expect(result).to.have.property('args');
76
- expect(invocationType).to.equal('RequestResponse');
77
74
 
78
75
  const { args } = result;
79
76
  expect(args).to.be.an('array').with.length(2);
@@ -86,7 +83,7 @@ describe('invokeFunction', function () {
86
83
  foo: 'foo',
87
84
  };
88
85
 
89
- const { result, invocationType } = await invokeFunction(
86
+ const { result } = await invokeFunction(
90
87
  'GoodFunction',
91
88
  event,
92
89
  { templatePath },
@@ -95,7 +92,6 @@ describe('invokeFunction', function () {
95
92
  expect(result).to.be.an('object');
96
93
  expect(result).to.have.property('env');
97
94
  expect(result).to.have.property('args');
98
- expect(invocationType).to.equal('RequestResponse');
99
95
 
100
96
  const { args } = result;
101
97
  expect(args).to.be.an('array').with.length(2);
@@ -107,7 +103,7 @@ describe('invokeFunction', function () {
107
103
  const envPath = path.resolve(__dirname, '../tests/assets/goodEnv.json');
108
104
  const event = {};
109
105
 
110
- const { result, invocationType } = await invokeFunction(
106
+ const { result } = await invokeFunction(
111
107
  'GoodFunction',
112
108
  event,
113
109
  { templatePath, envPath },
@@ -116,7 +112,6 @@ describe('invokeFunction', function () {
116
112
  expect(result).to.be.an('object');
117
113
  expect(result).to.have.property('env');
118
114
  expect(result).to.have.property('args');
119
- expect(invocationType).to.equal('RequestResponse');
120
115
 
121
116
  const { env } = result;
122
117
  expect(env).to.have.property('FOO', 'FOO');
@@ -161,13 +156,13 @@ describe('invokeFunction', function () {
161
156
  foo: 'foo',
162
157
  };
163
158
 
164
- const { invocationType } = await invokeFunction(
159
+ const { result } = await invokeFunction(
165
160
  'GoodAcyncFunction',
166
161
  event,
167
- { templatePath },
162
+ { templatePath, invocationType: 'Event' },
168
163
  );
169
164
 
170
- expect(invocationType).to.equal('Event');
165
+ expect(result).to.be.equal(undefined);
171
166
  });
172
167
 
173
168
  it('rejects when an error is thrown by the handler', async function () {
@@ -7,23 +7,31 @@ function getDebug(requestId) {
7
7
  }
8
8
 
9
9
  async function invokeHandler({
10
- absoluteIndexPath,
10
+ debugPortStart,
11
+ indexPath,
11
12
  handlerName,
12
13
  environment,
13
14
  event,
14
15
  keepAlive = false,
15
16
  requestId,
17
+ workingDirectory,
16
18
  }) {
17
19
  const id = requestId || generateRequestId();
18
20
  const debug = getDebug(id);
19
21
 
20
22
  const poolRequestId = keepAlive ? undefined : id;
21
- const workerPool = await getWorkerPool(absoluteIndexPath, handlerName, environment, poolRequestId);
23
+ const poolOptions = {
24
+ debugPortStart,
25
+ forkOpts: {
26
+ cwd: workingDirectory,
27
+ },
28
+ };
29
+ const workerPool = await getWorkerPool(indexPath, handlerName, environment, poolRequestId, poolOptions);
22
30
 
23
31
  try {
24
32
  debug('Start');
25
33
  const result = await workerPool.exec('callHandler', [{
26
- absoluteIndexPath,
34
+ indexPath,
27
35
  handlerName,
28
36
  event,
29
37
  environment: {
@@ -44,7 +52,7 @@ async function invokeHandler({
44
52
  throw e;
45
53
  } finally {
46
54
  if (!keepAlive) {
47
- await terminateWorkerPool(absoluteIndexPath, handlerName, poolRequestId);
55
+ await terminateWorkerPool(indexPath, handlerName, poolRequestId, poolOptions);
48
56
  }
49
57
  }
50
58
  }
@@ -23,11 +23,10 @@ describe('invokeHandler', function () {
23
23
  });
24
24
 
25
25
  it('invokes an async handler', async function () {
26
- const absoluteIndexPath = path.resolve(__dirname, '../tests/assets/goodHandler.js');
27
-
28
26
  const result = await invokeHandler({
29
- absoluteIndexPath,
30
27
  handlerName: 'handler',
28
+ indexPath: 'goodHandler.js',
29
+ workingDirectory: path.resolve(__dirname, '../tests/assets'),
31
30
  });
32
31
 
33
32
  expect(result).to.be.an('object');
@@ -36,11 +35,10 @@ describe('invokeHandler', function () {
36
35
  });
37
36
 
38
37
  it('invokes a non-async handler', async function () {
39
- const absoluteIndexPath = path.resolve(__dirname, '../tests/assets/goodCallbackHandler.js');
40
-
41
38
  const result = await invokeHandler({
42
- absoluteIndexPath,
43
39
  handlerName: 'handler',
40
+ indexPath: 'goodCallbackHandler.js',
41
+ workingDirectory: path.resolve(__dirname, '../tests/assets'),
44
42
  });
45
43
 
46
44
  expect(result).to.be.an('object');
@@ -49,14 +47,14 @@ describe('invokeHandler', function () {
49
47
  });
50
48
 
51
49
  it('invokes the handler with the given event', async function () {
52
- const absoluteIndexPath = path.resolve(__dirname, '../tests/assets/goodHandler.js');
53
50
  const event = {
54
51
  foo: 'foo',
55
52
  };
56
53
 
57
54
  const result = await invokeHandler({
58
- absoluteIndexPath,
59
55
  handlerName: 'handler',
56
+ indexPath: 'goodHandler.js',
57
+ workingDirectory: path.resolve(__dirname, '../tests/assets'),
60
58
  event,
61
59
  });
62
60
 
@@ -70,14 +68,14 @@ describe('invokeHandler', function () {
70
68
  });
71
69
 
72
70
  it('invokes the handler with the given environment variables', async function () {
73
- const absoluteIndexPath = path.resolve(__dirname, '../tests/assets/goodHandler.js');
74
71
  const environment = {
75
72
  FOO: 'FOO',
76
73
  };
77
74
 
78
75
  const result = await invokeHandler({
79
- absoluteIndexPath,
80
76
  handlerName: 'handler',
77
+ indexPath: 'goodHandler.js',
78
+ workingDirectory: path.resolve(__dirname, '../tests/assets'),
81
79
  environment,
82
80
  });
83
81
 
@@ -90,12 +88,12 @@ describe('invokeHandler', function () {
90
88
  });
91
89
 
92
90
  it('rejects when an error is thrown by an async handler', async function () {
93
- const absoluteIndexPath = path.resolve(__dirname, '../tests/assets/badHandler.js');
94
91
  const errorMessage = 'FOO';
95
92
 
96
93
  const invokePromise = invokeHandler({
97
- absoluteIndexPath,
98
94
  handlerName: 'handler',
95
+ indexPath: 'badHandler.js',
96
+ workingDirectory: path.resolve(__dirname, '../tests/assets'),
99
97
  event: { message: errorMessage },
100
98
  });
101
99
 
@@ -103,12 +101,12 @@ describe('invokeHandler', function () {
103
101
  });
104
102
 
105
103
  it('rejects when an error is returned by an non-async handler', async function () {
106
- const absoluteIndexPath = path.resolve(__dirname, '../tests/assets/badCallbackHandler.js');
107
104
  const errorMessage = 'FOO';
108
105
 
109
106
  const invokePromise = invokeHandler({
110
- absoluteIndexPath,
111
107
  handlerName: 'handler',
108
+ indexPath: 'badCallbackHandler.js',
109
+ workingDirectory: path.resolve(__dirname, '../tests/assets'),
112
110
  event: { message: errorMessage },
113
111
  });
114
112
 
@@ -116,12 +114,12 @@ describe('invokeHandler', function () {
116
114
  });
117
115
 
118
116
  it('rejects when the process dies unexpectedly', async function () {
119
- const absoluteIndexPath = path.resolve(__dirname, '../tests/assets/brokenHandler.js');
120
117
  const errorMessage = 'FOO';
121
118
 
122
119
  const invokePromise = invokeHandler({
123
- absoluteIndexPath,
124
120
  handlerName: 'handler',
121
+ indexPath: 'brokenHandler.js',
122
+ workingDirectory: path.resolve(__dirname, '../tests/assets'),
125
123
  event: { message: errorMessage },
126
124
  });
127
125
 
@@ -129,12 +127,12 @@ describe('invokeHandler', function () {
129
127
  });
130
128
 
131
129
  it('rejects when the handler function can\'t be found', async function () {
132
- const absoluteIndexPath = path.resolve(__dirname, '../tests/assets/goodHandler.js');
133
130
  const errorMessage = 'FOO';
134
131
 
135
132
  const invokePromise = invokeHandler({
136
- absoluteIndexPath,
133
+ indexPath: 'goodHandler.js',
137
134
  handlerName: 'foo',
135
+ workingDirectory: path.resolve(__dirname, '../tests/assets'),
138
136
  event: { message: errorMessage },
139
137
  });
140
138