Skip to content

Commit eb54845

Browse files
committed
Improve wording
1 parent 17e9ed7 commit eb54845

File tree

1 file changed

+12
-10
lines changed

1 file changed

+12
-10
lines changed

react-native.config.js

Lines changed: 12 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -3,33 +3,35 @@ const fs = require('fs/promises');
33
const path = require('path');
44
const pc = require('picocolors');
55

6-
// TODO: Improve wording (description, errors)
6+
const log = {
7+
error: (text) => console.log(pc.red(text)),
8+
warning: (text) => console.log('⚠️ ' + pc.yellow(text)),
9+
};
710

811
module.exports = {
912
commands: [
1013
{
1114
name: 'setup-ios-permissions',
12-
description: 'No description',
15+
description: 'Update react-native-permissions to link additional permission handlers.',
1316
func: async () => {
1417
const explorer = await cosmiconfig('iosPermissions');
1518
const result = await explorer.search();
1619

1720
if (!result) {
18-
console.log(pc.red('No config detected'));
21+
log.error(
22+
'No config detected. In order to setup iOS permissions, you first need to add an "iosPermissions" array in your package.json.',
23+
);
24+
1925
process.exit(1);
2026
}
2127

2228
const {config} = result;
2329

24-
if (!Array.isArray(config)) {
25-
console.log(pc.red('Invalid config'));
30+
if (!Array.isArray(config) || config.length === 0) {
31+
log.error('Invalid "iosPermissions" config detected. It must be a non-empty array.');
2632
process.exit(1);
2733
}
2834

29-
if (config.length === 0) {
30-
console.log(pc.yellow('Empty config'));
31-
}
32-
3335
const iosDirPath = path.join(__dirname, 'ios');
3436
const podspecPath = path.join(__dirname, 'RNPermissions.podspec');
3537
const iosDir = await fs.readdir(iosDirPath, {withFileTypes: true});
@@ -45,7 +47,7 @@ module.exports = {
4547
.map((name) => `"${name}"`);
4648

4749
if (unknownPermissions.length > 0) {
48-
console.log(pc.yellow(`Unknown permissions: ${unknownPermissions.join(', ')}`));
50+
log.warning(`Unknown iOS permissions: ${unknownPermissions.join(', ')}`);
4951
}
5052

5153
const sourceFiles = [

0 commit comments

Comments
 (0)