29 lines
920 B
JavaScript
29 lines
920 B
JavaScript
/**
|
|
* Smoke test: ctx.pear host imports under Pear (`pear://` import.meta.url).
|
|
* Usage (from repo root):
|
|
* node scripts/ensure-pear-node-modules.mjs packages/bare-os-booter
|
|
* cd packages/bare-os-booter && pear run --dev scripts/test-pear-ctx-load.mjs
|
|
*/
|
|
import { buildPearCtxObjectFromHost } from '../lib/ctx/bare-os-ctx-bare.js'
|
|
|
|
const pearBooter = String(import.meta.url || '').startsWith('pear:')
|
|
const target = {}
|
|
await buildPearCtxObjectFromHost({}, target)
|
|
|
|
/** @type {string[]} */
|
|
const always = ['pearBuild', 'bareBundleCompile', 'bareBundleEvaluate']
|
|
/** @type {string[]} */
|
|
const pearOnly = ['pearBundle', 'pearRef']
|
|
const keys = pearBooter ? [...always, ...pearOnly] : always
|
|
|
|
let failed = 0
|
|
for (const k of keys) {
|
|
const ok = target[k] !== undefined
|
|
console.log(`${k}: ${ok ? 'ok' : 'MISSING'}`)
|
|
if (!ok) failed++
|
|
}
|
|
|
|
if (failed > 0) {
|
|
throw new Error(`${failed} ctx.pear key(s) missing`)
|
|
}
|