tonylukasavage / tiapp.xml

Titanium tiapp.xml parsing and manipulation API
27 stars 10 forks source link

add() options #6

Closed tonylukasavage closed 10 years ago

tonylukasavage commented 10 years ago

All the add() function blindly adds a new node to the modules or plugins. It should actually prevent duplicates by default (based on id + platform), but be configurable to allow duplicates. It should also fail silently on duplicates, but this can be configurable too. Something like this:

tiapp.xml

<ti:app>
  <modules>
    <module platform="ios">foo</module>
  </modules> 
</ti:app>

test.js

// would quietly not do anything
tiapp.modules.add({ id: 'foo', platform: 'ios', version: '1.1' });

// would throw an error
tiapp.modules.add({ id: 'foo', platform: 'ios', version: '1.1' }, { fail: true });

// would write a 2nd entry for this module
tiapp.modules.add({ id: 'foo', platform: 'ios', version: '1.1' }, { duplicates: true });