Skip to content

Commit 93c23a7

Browse files
committed
feat: resolveBase param
1 parent 0b0a00d commit 93c23a7

File tree

1 file changed

+10
-5
lines changed

1 file changed

+10
-5
lines changed

packages/boot/tools/supports.ts

+10-5
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44
import childProcessAmbient from 'child_process';
55
import { promises as fsAmbientPromises } from 'fs';
66
import { resolve as importMetaResolve } from 'import-meta-resolve';
7+
import { createRequire } from 'node:module';
78
import { basename, join } from 'path';
89
import { inspect } from 'util';
910

@@ -52,14 +53,11 @@ import type { BridgeHandler, IBCDowncallMethod, IBCMethod } from '@agoric/vats';
5253
import type { BootstrapRootObject } from '@agoric/vats/src/core/lib-boot.js';
5354
import type { EProxy } from '@endo/eventual-send';
5455
import { tmpdir } from 'node:os';
56+
import { create } from 'node:domain';
5557
import { icaMocks, protoMsgMockMap, protoMsgMocks } from './ibc/mocks.js';
5658

5759
const trace = makeTracer('BSTSupport', false);
5860

59-
/** @param {string} spec package resource specifier */
60-
const importSpec = spec =>
61-
new URL(importMetaResolve(spec, import.meta.url)).pathname;
62-
6361
type ConsumeBootrapItem = <N extends string>(
6462
name: N,
6563
) => N extends keyof FastUSDCCorePowers['consume']
@@ -190,7 +188,11 @@ interface Powers {
190188
* @param powers.fs - Node fs/promises module for file operations
191189
* @returns A function that builds and extracts proposal data
192190
*/
193-
export const makeProposalExtractor = ({ childProcess, fs }: Powers) => {
191+
export const makeProposalExtractor = (
192+
{ childProcess, fs }: Powers,
193+
resolveBase = import.meta.url,
194+
) => {
195+
const importSpec = createRequire(resolveBase).resolve;
194196
const runPackageScript = (
195197
outputDir: string,
196198
scriptPath: string,
@@ -400,6 +402,7 @@ type AckBehaviorType = (typeof AckBehavior)[keyof typeof AckBehavior];
400402
* @param options.debugVats - Array of vat names to debug
401403
* @param options.defaultManagerType - SwingSet manager type to use
402404
* @param options.harness - Optional run harness
405+
* @param options.resolveBase - Base URL or path for resolving module paths
403406
* @returns A test kit with various utilities for interacting with the SwingSet
404407
*/
405408
export const makeSwingsetTestKit = async (
@@ -415,8 +418,10 @@ export const makeSwingsetTestKit = async (
415418
debugVats = [] as string[],
416419
defaultManagerType = 'local' as ManagerType,
417420
harness = undefined as RunHarness | undefined,
421+
resolveBase = import.meta.url,
418422
} = {},
419423
) => {
424+
const importSpec = createRequire(resolveBase).resolve;
420425
console.time('makeBaseSwingsetTestKit');
421426
const configPath = await getNodeTestVaultsConfig({
422427
bundleDir,

0 commit comments

Comments
 (0)