MCPcopy Create free account
hub / github.com/tiann/hapi / ensureRuntimeAssets

Function ensureRuntimeAssets

cli/src/runtime/assets.ts:138–165  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

136}
137
138export async function ensureRuntimeAssets(): Promise<void> {
139 if (!isBunCompiled()) {
140 return;
141 }
142
143 const { loadEmbeddedAssets } = await import('#embedded-assets');
144 const runtimeRoot = runtimePath();
145 const markerPath = join(runtimeRoot, RUNTIME_MARKER);
146 if (existsSync(markerPath)) {
147 const markerVersion = readFileSync(markerPath, 'utf-8').trim();
148 if (markerVersion === packageJson.version && runtimeAssetsReady(runtimeRoot)) {
149 return;
150 }
151 }
152
153 ensureDirectory(runtimeRoot);
154
155 const embeddedAssets = await loadEmbeddedAssets();
156
157 for (const asset of embeddedAssets) {
158 const targetPath = join(runtimeRoot, asset.relativePath);
159 await copyAssetFile(asset, targetPath);
160 }
161
162 unpackTools(runtimeRoot);
163 ensureTunwgExecutable(runtimeRoot);
164 writeFileSync(markerPath, packageJson.version, 'utf-8');
165}
166
167export function getTunwgPath(): string {
168 const isWin = platform() === 'win32';

Callers 1

runCliFunction · 0.90

Calls 8

isBunCompiledFunction · 0.90
runtimePathFunction · 0.90
runtimeAssetsReadyFunction · 0.85
ensureDirectoryFunction · 0.85
copyAssetFileFunction · 0.85
ensureTunwgExecutableFunction · 0.85
loadEmbeddedAssetsFunction · 0.70
unpackToolsFunction · 0.70

Tested by

no test coverage detected