Skip to content

Commit 23bdd2c

Browse files
committed
✨ Allows to override prefix
1 parent 60661ec commit 23bdd2c

File tree

1 file changed

+10
-6
lines changed

1 file changed

+10
-6
lines changed

lib.js

Lines changed: 10 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@ const DEFAULT_PREFIX = 'RN';
1212
const DEFAULT_MODULE_PREFIX = 'react-native';
1313
const DEFAULT_PACKAGE_IDENTIFIER = 'com.reactlibrary';
1414
const DEFAULT_PLATFORMS = ['android', 'ios', 'windows'];
15+
const DEFAULT_OVERRIDE_PREFIX = false;
1516

1617
module.exports = ({
1718
namespace,
@@ -20,14 +21,17 @@ module.exports = ({
2021
modulePrefix = DEFAULT_MODULE_PREFIX,
2122
packageIdentifier = DEFAULT_PACKAGE_IDENTIFIER,
2223
platforms = DEFAULT_PLATFORMS,
24+
overridePrefix = DEFAULT_OVERRIDE_PREFIX,
2325
}) => {
24-
if (hasPrefix(name)) {
25-
throw new Error('Please don\'t include the prefix in the name');
26-
}
26+
if (!overridePrefix) {
27+
if (hasPrefix(name)) {
28+
throw new Error('Please don\'t include the prefix in the name');
29+
}
2730

28-
if (prefix === 'RCT') {
29-
throw new Error(`The \`RCT\` name prefix is reserved for core React modules.
30-
Please use a different prefix.`);
31+
if (prefix === 'RCT') {
32+
throw new Error(`The \`RCT\` name prefix is reserved for core React modules.
33+
Please use a different prefix.`);
34+
}
3135
}
3236

3337
if (pathExists.sync(path.join(process.cwd(), 'package.json'))) {

0 commit comments

Comments
 (0)