Skip to content

Commit f7b8bc7

Browse files
committed
fix: make config plugin work without specifying props
1 parent 5d98a38 commit f7b8bc7

File tree

1 file changed

+19
-16
lines changed

1 file changed

+19
-16
lines changed

app.plugin.js

+19-16
Original file line numberDiff line numberDiff line change
@@ -36,14 +36,20 @@ const {
3636
*/
3737

3838
/**
39-
* @type {ConfigPlugin<{background: BackgroundConfig}>}
40-
*/
41-
const withEntitlementsPlugin = (config, { background }) => withEntitlementsPlist(config, (config) => {
39+
* @type {ConfigPlugin<{background: BackgroundConfig}>}
40+
*/
41+
const withEntitlementsPlugin = (
42+
config,
43+
/**
44+
* @type {{background: BackgroundConfig} | undefined}
45+
* */
46+
props,
47+
) => withEntitlementsPlist(config, (config) => {
4248
config.modResults['com.apple.developer.healthkit'] = true
4349

4450
// background is enabled by default, but possible to opt-out from
4551
// (haven't seen any drawbacks from having it enabled)
46-
if (background !== false) {
52+
if (props?.background !== false) {
4753
config.modResults['com.apple.developer.healthkit.background-delivery'] = true
4854
}
4955

@@ -55,18 +61,15 @@ const withEntitlementsPlugin = (config, { background }) => withEntitlementsPlist
5561
*/
5662
const withInfoPlistPlugin = (config,
5763
/**
58-
* @type {{NSHealthShareUsageDescription: string | boolean, NSHealthUpdateUsageDescription: string | boolean}}
64+
* @type {{NSHealthShareUsageDescription: string | boolean, NSHealthUpdateUsageDescription: string | boolean} | undefined}
5965
* */
60-
{
61-
NSHealthShareUsageDescription,
62-
NSHealthUpdateUsageDescription,
63-
}) => withInfoPlist(config, (config) => {
64-
if (NSHealthShareUsageDescription !== false) {
65-
config.modResults.NSHealthShareUsageDescription = NSHealthShareUsageDescription ?? `${config.name} wants to read your health data`
66+
props) => withInfoPlist(config, (config) => {
67+
if (props?.NSHealthShareUsageDescription !== false) {
68+
config.modResults.NSHealthShareUsageDescription = props.NSHealthShareUsageDescription ?? `${config.name} wants to read your health data`
6669
}
6770

68-
if (NSHealthUpdateUsageDescription !== false) {
69-
config.modResults.NSHealthUpdateUsageDescription = NSHealthUpdateUsageDescription ?? `${config.name} wants to update your health data`
71+
if (props?.NSHealthUpdateUsageDescription !== false) {
72+
config.modResults.NSHealthUpdateUsageDescription = props.NSHealthUpdateUsageDescription ?? `${config.name} wants to update your health data`
7073
}
7174

7275
return config
@@ -77,9 +80,9 @@ const pkg = require('./package.json')
7780
/**
7881
* @type {ConfigPlugin<AppPluginConfig>}
7982
*/
80-
const healthkitAppPlugin = (config, { NSHealthShareUsageDescription, NSHealthUpdateUsageDescription, background }) => withPlugins(config, [
81-
[withEntitlementsPlugin, { background }],
82-
[withInfoPlistPlugin, { NSHealthShareUsageDescription, NSHealthUpdateUsageDescription }],
83+
const healthkitAppPlugin = (config, props) => withPlugins(config, [
84+
[withEntitlementsPlugin, props],
85+
[withInfoPlistPlugin, props],
8386
])
8487

8588
/**

0 commit comments

Comments
 (0)