forked from apollohg/react-native-prose-editor
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathapp.plugin.js
More file actions
62 lines (51 loc) · 1.58 KB
/
Copy pathapp.plugin.js
File metadata and controls
62 lines (51 loc) · 1.58 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
const path = require('path');
const { createRequire } = require('module');
const pkg = require('./package.json');
const PACKAGING_EXCLUDES_PROPERTY = 'android.packagingOptions.excludes';
const LEGACY_JNA_ABI_EXCLUDES = [
'**/armeabi/libjnidispatch.so',
'**/mips/libjnidispatch.so',
'**/mips64/libjnidispatch.so',
];
function requireExpoConfigPlugins() {
try {
return require('expo/config-plugins');
} catch (error) {
if (error.code !== 'MODULE_NOT_FOUND') {
throw error;
}
const appRequire = createRequire(path.join(process.cwd(), 'package.json'));
return appRequire('expo/config-plugins');
}
}
function mergeCommaList(value, additions) {
const values = (value || '')
.split(',')
.map((item) => item.trim())
.filter(Boolean);
return Array.from(new Set([...values, ...additions])).join(',');
}
function withOpenEditorReactNativeProseEditor(config) {
const { withGradleProperties } = requireExpoConfigPlugins();
return withGradleProperties(config, (config) => {
const existing = config.modResults.find(
(property) => property.type === 'property' && property.key === PACKAGING_EXCLUDES_PROPERTY
);
const value = mergeCommaList(existing && existing.value, LEGACY_JNA_ABI_EXCLUDES);
if (existing) {
existing.value = value;
} else {
config.modResults.push({
type: 'property',
key: PACKAGING_EXCLUDES_PROPERTY,
value,
});
}
return config;
});
}
module.exports = requireExpoConfigPlugins().createRunOncePlugin(
withOpenEditorReactNativeProseEditor,
pkg.name,
pkg.version
);