Skip to content

Commit a26d8b8

Browse files
author
Christopher J. Brody
committed
--module-name option
1 parent 21e7260 commit a26d8b8

3 files changed

Lines changed: 15 additions & 7 deletions

File tree

README.md

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -62,7 +62,8 @@ Options:
6262
6363
--help output usage information
6464
--prefix <prefix> The prefix for the library (Default: ``)
65-
--module-prefix <modulePrefix> The module prefix for the library (Default: `react-native`)
65+
--module-name <moduleName> The module library package name to be used in package.json. Default: react-native-(name in param-case)
66+
--module-prefix <modulePrefix> The module prefix for the library, ignored if --module-name is specified (Default: `react-native`)
6667
--package-identifier <packageIdentifier> (Android only!) The package name for the Android module (Default: `com.reactlibrary`)
6768
--platforms <platforms> Platforms the library will be created for. (comma separated; default: `ios,android`)
6869
--github-account <github_account> The github account where the library is hosted (Default: `github_account`)
@@ -91,7 +92,8 @@ createLibrary({
9192
{
9293
name: String, /* The name of the library (Default: Library) */
9394
prefix: String, /* The prefix for the library (Default: RN) */
94-
modulePrefix: String, /* The module prefix for the library (Default: react-native) */
95+
moduleName: String, /* The module library package name to be used in package.json. Default: react-native-(name in param-case) */
96+
modulePrefix: String, /* The module prefix for the library, ignored if moduleName is specified (Default: react-native) */
9597
platforms: Array, /* Platforms the library will be created for. (Default: ['ios', 'android']) */
9698
packageIdentifier: String, /* (Android only!) The package name for the Android module (Default: com.reactlibrary) */
9799
githubAccount: String, /* The github account where the library is hosted (Default: `github_account`) */

command.js

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ module.exports = {
99
func: (args, config, options) => {
1010
const name = args[0];
1111
const prefix = options.prefix;
12+
const moduleName = options.moduleName;
1213
const modulePrefix = options.modulePrefix;
1314
const packageIdentifier = options.packageIdentifier;
1415
const platforms = (options.platforms) ? options.platforms.split(',') : options.platforms;
@@ -23,6 +24,7 @@ module.exports = {
2324
createLibrary({
2425
name,
2526
prefix,
27+
moduleName,
2628
modulePrefix,
2729
packageIdentifier,
2830
platforms,
@@ -49,9 +51,12 @@ ${emoji.get('arrow_right')} To get started type \`cd ./${name}\` and run \`npm
4951
command: '--prefix [prefix]',
5052
description: 'The prefix for the library module (Default: ``)',
5153
default: '',
54+
}, {
55+
command: '--module-name [moduleName]',
56+
description: 'The module library package name to be used in package.json. Default: react-native-(name in param-case)',
5257
}, {
5358
command: '--module-prefix [modulePrefix]',
54-
description: 'The module prefix for the library module (Default: `react-native`)',
59+
description: 'The module prefix for the library module, ignored if --module-name is specified (Default: `react-native`)',
5560
default: 'react-native',
5661
}, {
5762
command: '--package-identifier [packageIdentifier]',

lib.js

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,7 @@ const renderTemplate = renderTemplateIfValid;
3636
module.exports = ({
3737
name = DEFAULT_NAME,
3838
prefix = DEFAULT_PREFIX,
39+
moduleName = null,
3940
modulePrefix = DEFAULT_MODULE_PREFIX,
4041
packageIdentifier = DEFAULT_PACKAGE_IDENTIFIER,
4142
platforms = DEFAULT_PLATFORMS,
@@ -76,9 +77,9 @@ module.exports = ({
7677
}
7778

7879
const className = `${prefix}${pascalCase(name)}`;
79-
const moduleName = `${modulePrefix}-${paramCase(name)}`;
80+
const rootName = moduleName || `${modulePrefix}-${paramCase(name)}`;
8081
const namespace = pascalCase(name).split(/(?=[A-Z])/).join('.');
81-
const rootFolderName = moduleName;
82+
const rootFolderName = rootName;
8283

8384
return createFolder(rootFolderName)
8485
.then(() => {
@@ -94,7 +95,7 @@ module.exports = ({
9495
}
9596
const templateArgs = {
9697
name: className,
97-
moduleName,
98+
moduleName: rootName,
9899
packageIdentifier,
99100
namespace,
100101
platforms,
@@ -123,7 +124,7 @@ module.exports = ({
123124

124125
const templateArgs = {
125126
name: className,
126-
moduleName,
127+
moduleName: rootName,
127128
view,
128129
};
129130

0 commit comments

Comments
 (0)