spec-up-t 1.0.2 → 1.0.3

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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "spec-up-t",
3
- "version": "1.0.2",
3
+ "version": "1.0.3",
4
4
  "description": "Technical specification drafting tool that generates rich specification documents from markdown. Forked from https://github.com/decentralized-identity/spec-up by Daniel Buchner (https://github.com/csuwildcat)",
5
5
  "main": "./index",
6
6
  "repository": {
@@ -286,39 +286,46 @@ function getXrefsData() {
286
286
  // Write function that removes an entry from xrefs-data.json and xrefs-data.js based on the term and externalSpec
287
287
  function removeXref(term, externalSpec) {
288
288
  let messages = [];
289
-
290
- // Read the JSON file
291
- let currentXrefs = fs.readJsonSync(outputPathJSON);
292
289
 
293
- // Check if the term and externalSpec exist
294
- const entryExists = currentXrefs.xrefs.some(xref => xref.term === term && xref.externalSpec === externalSpec);
290
+ try {
291
+ // Read the JSON file
292
+ let currentXrefs = fs.readJsonSync(outputPathJSON);
295
293
 
296
- if (!entryExists) {
297
- messages.push(`\n SPEC-UP-T: Entry with term "${term}" and externalSpec "${externalSpec}" not found.\n`);
298
- return messages;
299
- }
294
+ // Check if the term and externalSpec exist
295
+ const entryExists = currentXrefs.xrefs.some(xref => xref.term === term && xref.externalSpec === externalSpec);
300
296
 
301
- // Remove the entry from the JSON file
302
- currentXrefs.xrefs = currentXrefs.xrefs.filter(xref => {
303
- return !(xref.term === term && xref.externalSpec === externalSpec);
304
- });
297
+ if (!entryExists) {
298
+ messages.push(`\n SPEC-UP-T: Entry with term "${term}" and externalSpec "${externalSpec}" not found.\n`);
299
+ return messages;
300
+ }
305
301
 
306
- // Convert the JSON object back to a JSON string
307
- const currentXrefsStr = JSON.stringify(currentXrefs, null, 2);
302
+ // Remove the entry from the JSON file
303
+ currentXrefs.xrefs = currentXrefs.xrefs.filter(xref => {
304
+ return !(xref.term === term && xref.externalSpec === externalSpec);
305
+ });
308
306
 
309
- // Write the JSON code to a .json file
310
- fs.writeFileSync(outputPathJSON, currentXrefsStr, 'utf8');
307
+ // Convert the JSON object back to a JSON string
308
+ const currentXrefsStr = JSON.stringify(currentXrefs, null, 2);
311
309
 
312
- // Create the JS code for the assignment
313
- const stringReadyForFileWrite = `const allXrefs = ${currentXrefsStr};`;
310
+ // Write the JSON code to a .json file
311
+ fs.writeFileSync(outputPathJSON, currentXrefsStr, 'utf8');
314
312
 
315
- // Write the JS code to a .js file
316
- fs.writeFileSync(outputPathJS, stringReadyForFileWrite, 'utf8');
313
+ // Create the JS code for the assignment
314
+ const stringReadyForFileWrite = `const allXrefs = ${currentXrefsStr};`;
317
315
 
318
- messages.push(`\n SPEC-UP-T: Entry with term "${term}" and externalSpec "${externalSpec}" removed.\n`);
316
+ // Write the JS code to a .js file
317
+ fs.writeFileSync(outputPathJS, stringReadyForFileWrite, 'utf8');
318
+
319
+ messages.push(`\n SPEC-UP-T: Entry with term "${term}" and externalSpec "${externalSpec}" removed.\n`);
320
+ } catch (error) {
321
+ messages.push(`\n SPEC-UP-T: An error occurred - ${error.message}\n`);
322
+ }
323
+
324
+ // TODO: messages are not used at the moment, since they apparently are not returned to the calling script. Fix this.
319
325
  return messages;
320
326
  }
321
327
 
328
+
322
329
  module.exports = {
323
330
  getXrefsData,
324
331
  removeXref