Skip to content

Commit

Permalink
Using pathToFileURL to import handler method across OS's (#189)
Browse files Browse the repository at this point in the history
  • Loading branch information
dsarlo authored Oct 30, 2023
1 parent 9032a77 commit 153c9e0
Showing 1 changed file with 2 additions and 1 deletion.
3 changes: 2 additions & 1 deletion src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ import lodashfp from 'lodash/fp.js';
const { get, has } = lodashfp;

import { loadServerlessConfig } from "./sls-config-parser.js";
import url from 'url';

class ServerlessOfflineSns {
private config: any;
Expand Down Expand Up @@ -509,7 +510,7 @@ class ServerlessOfflineSns {
const handlerPath = fn.handler.substring(0, handlerFnNameIndex);
const handlerFnName = fn.handler.substring(handlerFnNameIndex + 1);
const fullHandlerPath = resolve(location, handlerPath);
const handlers = await import(`${fullHandlerPath}.js`);
const handlers = await import(`${url.pathToFileURL(fullHandlerPath)}.js`);
return handlers[handlerFnName];
}

Expand Down

0 comments on commit 153c9e0

Please sign in to comment.