-
Notifications
You must be signed in to change notification settings - Fork 192
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
4 changed files
with
42 additions
and
31 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
// not intended to be loaded via require() - copied during build step | ||
import { createRequire } from 'module'; | ||
import path from 'node:path'; | ||
import zapier from 'zapier-platform-core'; | ||
|
||
const require = createRequire(import.meta.url); | ||
let appPath; | ||
|
||
try { | ||
appPath = require.resolve(process.cwd()); | ||
} catch (e) { | ||
// if it failed, try to resolve the app path with self-referencing | ||
// in case index.js is not in the root directory | ||
try { | ||
appPath = require.resolve(path.basename(process.cwd())); | ||
} catch (e2) { | ||
throw new Error("Failed to resolve app path - make sure you have a package.json in the root directory"); | ||
} | ||
} | ||
|
||
export { appPath }; | ||
export const handler = zapier.createAppHandler(appPath); |