@itentialopensource/adapter-kafkav2 0.16.0 → 0.16.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +8 -0
- package/adapter.js +21 -3
- package/package.json +1 -1
- package/refs?service=git-upload-pack +0 -0
package/CHANGELOG.md
CHANGED
package/adapter.js
CHANGED
|
@@ -181,13 +181,31 @@ class Kafkav2 extends AdapterBaseCl {
|
|
|
181
181
|
this.topicsEvents = [];
|
|
182
182
|
let topicsFile = path.join(__dirname, `/.topics-${this.id}.json`);
|
|
183
183
|
|
|
184
|
-
// if the file
|
|
184
|
+
// Check if the file exists
|
|
185
185
|
if (fs.existsSync(topicsFile)) {
|
|
186
|
-
|
|
186
|
+
const fileContent = fs.readFileSync(topicsFile, 'utf-8');
|
|
187
|
+
|
|
188
|
+
// Check if the file is empty
|
|
189
|
+
if (fileContent.trim() === '') {
|
|
190
|
+
// If it's empty, write an empty array to the file
|
|
191
|
+
fs.writeFileSync(topicsFile, '[]');
|
|
192
|
+
} else {
|
|
193
|
+
// Parse the existing content
|
|
194
|
+
this.topicsEvents = JSON.parse(fileContent);
|
|
195
|
+
}
|
|
187
196
|
} else if (fs.existsSync(path.join(__dirname, '/.topics.json'))) {
|
|
188
197
|
log.debug('Found old .topics.json file.');
|
|
189
198
|
topicsFile = path.join(__dirname, '/.topics.json');
|
|
190
|
-
|
|
199
|
+
const fileContent = fs.readFileSync(topicsFile, 'utf-8');
|
|
200
|
+
|
|
201
|
+
// Check if the file is empty
|
|
202
|
+
if (fileContent.trim() === '') {
|
|
203
|
+
// If it's empty, write an empty array to the file
|
|
204
|
+
fs.writeFileSync(topicsFile, '[]');
|
|
205
|
+
} else {
|
|
206
|
+
// Parse the existing content
|
|
207
|
+
this.topicsEvents = JSON.parse(fileContent);
|
|
208
|
+
}
|
|
191
209
|
}
|
|
192
210
|
|
|
193
211
|
// get the topics into the right format --- fix older .topics.json files so they have the right format
|
package/package.json
CHANGED
|
Binary file
|