UNPKG

@enspirit/emb

Version:

A replacement for our Makefile-for-monorepos

30 lines (29 loc) 942 B
import { dirname, join } from 'node:path'; import { fileURLToPath } from 'node:url'; import protobuf from 'protobufjs'; let control; export const loadControl = async () => { if (control) { return control; } const path = join(dirname(fileURLToPath(import.meta.url)), './control.proto'); control = await protobuf.load(path); return control; }; export const decodeBuildkitStatusResponse = async (str) => { const control = await loadControl(); const buffer = typeof str === 'string' ? Buffer.from(str, 'base64') : str; const uint8 = new Uint8Array(buffer); const Trace = control.lookupType('moby.buildkit.v1.StatusResponse'); const message = Trace.decode(uint8); const object = Trace.toObject(message, { arrays: true, bytes: String, defaults: true, enums: String, longs: String, objects: true, oneofs: true, }); return object; };