Skip to content

Commit 194f85a

Browse files
committed
fix: include sparkplug proto in build
this isn't the ideal way to include the proto definition, but the build system for this project is too convoluted for my smooth brain to understand
1 parent 4093a48 commit 194f85a

File tree

2 files changed

+4
-2
lines changed

2 files changed

+4
-2
lines changed

backend/src/Model/sparkplugb.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,9 +2,9 @@ import { readFileSync } from 'fs'
22
import * as protobuf from 'protobufjs'
33
import { Base64Message } from './Base64Message'
44
import { Decoder } from './Decoder'
5+
import { protobufStr } from './sparkplugb_proto'
56

6-
const buffer = readFileSync(require.resolve('../../../../res/sparkplug_b.proto'))
7-
const root = protobuf.parse(buffer.toString()).root
7+
const root = protobuf.parse(protobufStr).root
88
export let SparkplugPayload = root.lookupType('com.cirruslink.sparkplug.protobuf.Payload')
99

1010
export const SparkplugDecoder = {

res/sparkplug_b.proto renamed to backend/src/Model/sparkplugb_proto.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
export const protobufStr = `
12
syntax = "proto2";
23
34
//
@@ -195,3 +196,4 @@ message Payload {
195196
optional bytes body = 5; // To optionally bypass the whole definition above
196197
extensions 6 to max; // For third party extensions
197198
}
199+
`

0 commit comments

Comments
 (0)