Skip to content

implement setPreference and setPlatformPreference#63

Merged
dpogue merged 1 commit into
apache:masterfrom
blackthornio:support-set-platform-preference
Apr 14, 2019
Merged

implement setPreference and setPlatformPreference#63
dpogue merged 1 commit into
apache:masterfrom
blackthornio:support-set-platform-preference

Conversation

@crysislinux

Copy link
Copy Markdown
Contributor

Platforms affected

None or All, it will not affect any existing code, just provides new APIs

What does this PR do?

Support set the preference for a specific platform. Currently, only global preference is supported by the cordova-common. We have used the new API to implement a hook which will update platform preference in config.xml

What testing has been done on this change?

Four unit tests are added. The new added tests don't have Test ${number} prefix bc that would lead to a lot of changes in unrelated tests.

@dpogue dpogue left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

👍 from me

@dpogue dpogue merged commit a5cd232 into apache:master Apr 14, 2019
setPlatformPreference: function (name, platform, value) {
const platformEl = this.doc.find('./platform[@name="' + platform + '"]');
if (!platformEl) {
throw new CordovaError('platform does not exist (received platform: ' + platform + ')');

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Wouldn't it be nicer if we created the platform element here instead of throwing?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I guess it's much simpler to just throw. A new platform won't work automatically by just add a new section in the config.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants