Skip to content

Commit

Permalink
fix(bundle-source): Avoid ?? operator for RESM
Browse files Browse the repository at this point in the history
  • Loading branch information
kriskowal committed Dec 19, 2023
1 parent 9c2445e commit 3355c04
Showing 1 changed file with 8 additions and 1 deletion.
9 changes: 8 additions & 1 deletion packages/bundle-source/src/is-entrypoint.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,14 @@ import url from 'url';
import process from 'process';
import fs from 'fs';

// Agoric still uses Endo dependencies under an emulation of ESM we call RESM
// because it is invoked with `node -r esm`.
// RESM does not support ?? nor ?. operators, so we must avoid them expressly.
// TODO remove when https://github.com/Agoric/agoric-sdk/issues/8671
const favor = (primary, secondary) =>
primary === undefined ? secondary : primary;

// FIXME: Should maybe be exported by '@endo/something'?
export const isEntrypoint = href =>
String(href) ===
url.pathToFileURL(fs.realpathSync(process.argv[1]) ?? '/').href;
url.pathToFileURL(fs.realpathSync(favor(process.argv[1]), '/')).href;

0 comments on commit 3355c04

Please sign in to comment.