Skip to content

Commit

Permalink
fix: do not add react-native package prefix if not needed (#435)
Browse files Browse the repository at this point in the history
* fix: do not add react-native package prefix if not needed
* add test
* add test snapshot
  • Loading branch information
Chris Brody authored Mar 16, 2021
1 parent 254ab07 commit 8f8a9c5
Show file tree
Hide file tree
Showing 3 changed files with 814 additions and 5 deletions.
15 changes: 10 additions & 5 deletions lib/normalized-options.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,15 @@ const { paramCase } = require('param-case');

const { pascalCase } = require('pascal-case');

const PACKAGE_PREFIX = 'react-native';
const PACKAGE_NAME_PREFIX = 'react-native-';

function transformPackageName (name) {
const paramCaseName = paramCase(name);

return paramCaseName.startsWith(PACKAGE_NAME_PREFIX)
? paramCaseName
: PACKAGE_NAME_PREFIX + paramCaseName;
}

module.exports = (options) => {
const { name, packageName, objectClassName } = options;
Expand All @@ -20,10 +28,7 @@ module.exports = (options) => {
options,
packageName
? {}
: {
// TODO: do not add PACKAGE_PREFIX if it is not needed
packageName: `${PACKAGE_PREFIX}-${paramCase(name)}`
},
: { packageName: transformPackageName(name) },
objectClassName
? {}
: { objectClassName: `${pascalCase(name)}` },
Expand Down
Loading

0 comments on commit 8f8a9c5

Please sign in to comment.