Skip to content

Commit b4cb27b

Browse files
author
Chris Brody
authored
quick commander@5 update (#297)
* quick commander@5 update * cleanup: rename internal action function & drop argument not needed
1 parent 9712d41 commit b4cb27b

File tree

12 files changed

+20
-24
lines changed

12 files changed

+20
-24
lines changed

lib/cli-command.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@ module.exports = {
4040
name: 'create-library',
4141
description: 'creates a React Native library module for one or more platforms',
4242
usage: '[options] <name>',
43-
func: (args, config, options) => {
43+
action: (args, options) => {
4444
const name = args[0];
4545

4646
const beforeCreation = Date.now();

lib/cli-program.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,8 +13,8 @@ program
1313
.version(pkg.version)
1414
.usage(command.usage)
1515
.description(command.description)
16-
.action(function runAction () {
17-
command.func(arguments, {}, this.opts());
16+
.action(function programAction (_, args) {
17+
command.action(args, this.opts());
1818
});
1919

2020
(command.options || [])

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@
4343
},
4444
"homepage": "https://github.com/brodybits/create-react-native-module#readme",
4545
"dependencies": {
46-
"commander": "^3.0.1",
46+
"commander": "^5.0.0",
4747
"execa": "^3.3.0",
4848
"fs-extra": "^8.1.0",
4949
"jsonfile": "^6.0.0",

tests/integration/cli/help/__snapshots__/cli-help.test.js.snap

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,5 +24,5 @@ Options:
2424
--example-name [exampleName] Name for the example project (default: \\"example\\")
2525
--example-react-native-version [exampleReactNativeVersion] React Native version for the generated example project (default: \\"react-native@latest\\")
2626
--write-example-podfile [iOS] EXPERIMENTAL FEATURE NOT SUPPORTED: write (or overwrite) example ios/Podfile
27-
-h, --help output usage information"
27+
-h, --help display help for command"
2828
`;

tests/integration/cli/noargs/__snapshots__/cli-noargs.test.js.snap

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,5 +24,5 @@ Options:
2424
--example-name [exampleName] Name for the example project (default: \\"example\\")
2525
--example-react-native-version [exampleReactNativeVersion] React Native version for the generated example project (default: \\"react-native@latest\\")
2626
--write-example-podfile [iOS] EXPERIMENTAL FEATURE NOT SUPPORTED: write (or overwrite) example ios/Podfile
27-
-h, --help output usage information"
27+
-h, --help display help for command"
2828
`;

tests/with-injection/cli/command/object/__snapshots__/lib-cli-command-object-text.test.js.snap

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,8 @@
22

33
exports[`cli-command object 1`] = `
44
Object {
5+
"action": [Function],
56
"description": "creates a React Native library module for one or more platforms",
6-
"func": [Function],
77
"name": "create-library",
88
"options": Array [
99
Object {

tests/with-mocks/cli/command/func/with-logging/with-bogus-platforms/bogus-name/cli-command-with-bogus-platforms-name.test.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
const func = require('../../../../../../../../lib/cli-command.js').func;
1+
const action = require('../../../../../../../../lib/cli-command.js').action;
22

33
// special compact mocks for this test:
44
const mysnap = [];
@@ -38,7 +38,7 @@ test(`create alice-bobbi module with logging, with platforms: 'bogus'`, async ()
3838

3939
const options = { platforms: 'bogus' };
4040

41-
await func(args, null, options);
41+
await action(args, options);
4242

4343
expect(mysnap).toMatchSnapshot();
4444
});

tests/with-mocks/cli/command/func/with-logging/with-bogus-platforms/empty-string/cli-command-with-empty-platforms-string.test.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
const func = require('../../../../../../../../lib/cli-command.js').func;
1+
const action = require('../../../../../../../../lib/cli-command.js').action;
22

33
// special compact mocks for this test:
44
const mysnap = [];
@@ -38,7 +38,7 @@ test(`create alice-bobbi module with logging, with platforms: ''`, async () => {
3838

3939
const options = { platforms: '' };
4040

41-
await func(args, null, options);
41+
await action(args, options);
4242

4343
expect(mysnap).toMatchSnapshot();
4444
});

tests/with-mocks/cli/command/func/with-logging/with-error/cli-command-with-logging-with-error.test.js

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
const func = require('../../../../../../../lib/cli-command.js').func;
1+
const action = require('../../../../../../../lib/cli-command.js').action;
22

33
// special compact mocks for this test:
44
const mysnap = [];
@@ -61,9 +61,7 @@ global.console = {
6161
test('create alice-bobbi module with logging, with fs error (with defaults for Android & iOS)', async () => {
6262
const args = ['alice-bobbi'];
6363

64-
const config = 'bogus';
65-
66-
await func(args, config, {});
64+
await action(args, {});
6765

6866
expect(mysnap).toMatchSnapshot();
6967
});

tests/with-mocks/cli/command/func/with-options/cli-command-func-with-options.test.js

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
const func = require('../../../../../../lib/cli-command.js').func;
1+
const action = require('../../../../../../lib/cli-command.js').action;
22

33
// special compact mocks for this test:
44
const mysnap = [];
@@ -20,8 +20,6 @@ jest.mock('fs-extra', () => ({
2020
test('create alice-bobbi module with explicit config options for Android & iOS', () => {
2121
const args = ['alice-bobbi'];
2222

23-
const config = 'bogus';
24-
2523
const options = {
2624
platforms: 'android,ios',
2725
tvosEnabled: true,
@@ -31,6 +29,6 @@ test('create alice-bobbi module with explicit config options for Android & iOS',
3129
license: 'ISC',
3230
};
3331

34-
return func(args, config, options)
32+
return action(args, options)
3533
.then(() => { expect(mysnap).toMatchSnapshot(); });
3634
});

0 commit comments

Comments
 (0)