Skip to content

Commit

Permalink
PDE-4678 fix(cli): Use findCorePackageDir() utility method when impor…
Browse files Browse the repository at this point in the history
…ting zapier-platform-core (#746)

Co-authored-by: Raúl Negrón <[email protected]>
  • Loading branch information
rnegron and rnegron authored Feb 8, 2024
1 parent e3b3e23 commit 47d2a50
Showing 1 changed file with 4 additions and 2 deletions.
6 changes: 4 additions & 2 deletions packages/cli/src/utils/local.js
Original file line number Diff line number Diff line change
@@ -1,11 +1,13 @@
const _ = require('lodash');
const path = require('path');

const { PLATFORM_PACKAGE } = require('../constants');
const { findCorePackageDir } = require('./misc');

const getLocalAppHandler = ({ reload = false, baseEvent = {} } = {}) => {
const entryPath = `${process.cwd()}/index`;
const rootPath = path.dirname(require.resolve(entryPath));
const corePackageDir = findCorePackageDir();

if (reload) {
Object.keys(require.cache).forEach((cachePath) => {
if (cachePath.startsWith(rootPath)) {
Expand All @@ -16,7 +18,7 @@ const getLocalAppHandler = ({ reload = false, baseEvent = {} } = {}) => {
let appRaw, zapier;
try {
appRaw = require(entryPath);
zapier = require(PLATFORM_PACKAGE);
zapier = require(corePackageDir);
} catch (err) {
// this err.stack doesn't give a nice traceback at all :-(
// maybe we could do require('syntax-error') in the future
Expand Down

0 comments on commit 47d2a50

Please sign in to comment.