@@ -237,7 +237,6 @@ async function exportPredicate(
237237 ajSettings : aj . Settings
238238) {
239239 console . groupCollapsed ( 'Export Predicate Model' )
240- const projectName = safeFunctionName ( ajSettings . projectName )
241240
242241 const predicateJSON = {
243242 parent : 'item/generated' ,
@@ -249,6 +248,7 @@ async function exportPredicate(
249248 includedRigs : { } ,
250249 } ,
251250 }
251+
252252 let usedIDs = [ ]
253253 function * idGen ( ) {
254254 let id = 1
@@ -257,12 +257,24 @@ async function exportPredicate(
257257 id ++
258258 }
259259 }
260+
260261 if ( fs . existsSync ( ajSettings . predicateFilePath ) ) {
261- const oldPredicate : PredicateModel = JSON . parse (
262- await fs . promises . readFile ( ajSettings . predicateFilePath , {
262+ const stringContent = await fs . promises . readFile (
263+ ajSettings . predicateFilePath ,
264+ {
263265 encoding : 'utf-8' ,
264- } )
266+ }
265267 )
268+ let oldPredicate : PredicateModel
269+ try {
270+ oldPredicate = JSON . parse ( stringContent )
271+ } catch ( err ) {
272+ throwPredicateMergingError (
273+ tl (
274+ 'animatedJava.dialogs.errors.predicateMergeFailed.reasons.invalidJson'
275+ )
276+ )
277+ }
266278 console . log ( oldPredicate )
267279 // @ts -ignore
268280 if ( oldPredicate ) {
@@ -347,8 +359,8 @@ async function exportPredicate(
347359 } )
348360 }
349361
350- predicateJSON . overrides . sort ( ( a : any , b : any ) => {
351- return ( a . predicate . custom_model_data - b . predicate . custom_model_data )
362+ predicateJSON . overrides . sort ( ( a : any , b : any ) => {
363+ return a . predicate . custom_model_data - b . predicate . custom_model_data
352364 } )
353365 //@ts -ignore
354366 predicateJSON . aj . includedRigs [ Project . UUID ] = {
0 commit comments