Skip to content

Commit

Permalink
Update config key
Browse files Browse the repository at this point in the history
  • Loading branch information
zoontek committed Feb 26, 2023
1 parent 3d147b2 commit ffebb54
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 4 deletions.
2 changes: 1 addition & 1 deletion example/package.json
Expand Up @@ -11,7 +11,7 @@
"start": "react-native start",
"reinstall": "yarn clean && yarn install"
},
"iosPermissions": [
"reactNativePermissionsIOS": [
"AppTrackingTransparency",
"BluetoothPeripheral",
"Calendars",
Expand Down
8 changes: 5 additions & 3 deletions react-native.config.js
Expand Up @@ -3,6 +3,8 @@ const fs = require('fs/promises');
const path = require('path');
const pc = require('picocolors');

const CONFIG_KEY = 'reactNativePermissionsIOS';

const log = {
error: (text) => console.log(pc.red(text)),
warning: (text) => console.log(pc.yellow(text)),
Expand All @@ -15,12 +17,12 @@ module.exports = {
description:
'Update react-native-permissions podspec to link additional permission handlers.',
func: async () => {
const explorer = await cosmiconfig('iosPermissions');
const explorer = await cosmiconfig(CONFIG_KEY);
const result = await explorer.search();

if (!result) {
log.error(
'No config detected. In order to setup iOS permissions, you first need to add an "iosPermissions" array in your package.json.',
`No config detected. In order to setup iOS permissions, you first need to add an "${CONFIG_KEY}" array in your package.json.`,
);

process.exit(1);
Expand All @@ -29,7 +31,7 @@ module.exports = {
const {config} = result;

if (!Array.isArray(config) || config.length === 0) {
log.error('Invalid "iosPermissions" config detected. It must be a non-empty array.');
log.error(`Invalid "${CONFIG_KEY}" config detected. It must be a non-empty array.`);
process.exit(1);
}

Expand Down

0 comments on commit ffebb54

Please sign in to comment.