Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

quick commander@5 update #297

Merged
merged 2 commits into from
Apr 2, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion lib/cli-command.js
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ module.exports = {
name: 'create-library',
description: 'creates a React Native library module for one or more platforms',
usage: '[options] <name>',
func: (args, config, options) => {
action: (args, options) => {
const name = args[0];

const beforeCreation = Date.now();
Expand Down
4 changes: 2 additions & 2 deletions lib/cli-program.js
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,8 @@ program
.version(pkg.version)
.usage(command.usage)
.description(command.description)
.action(function runAction () {
command.func(arguments, {}, this.opts());
.action(function programAction (_, args) {
command.action(args, this.opts());
});

(command.options || [])
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@
},
"homepage": "https://github.com/brodybits/create-react-native-module#readme",
"dependencies": {
"commander": "^3.0.1",
"commander": "^5.0.0",
"execa": "^3.3.0",
"fs-extra": "^8.1.0",
"jsonfile": "^6.0.0",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,5 +24,5 @@ Options:
--example-name [exampleName] Name for the example project (default: \\"example\\")
--example-react-native-version [exampleReactNativeVersion] React Native version for the generated example project (default: \\"react-native@latest\\")
--write-example-podfile [iOS] EXPERIMENTAL FEATURE NOT SUPPORTED: write (or overwrite) example ios/Podfile
-h, --help output usage information"
-h, --help display help for command"
`;
Original file line number Diff line number Diff line change
Expand Up @@ -24,5 +24,5 @@ Options:
--example-name [exampleName] Name for the example project (default: \\"example\\")
--example-react-native-version [exampleReactNativeVersion] React Native version for the generated example project (default: \\"react-native@latest\\")
--write-example-podfile [iOS] EXPERIMENTAL FEATURE NOT SUPPORTED: write (or overwrite) example ios/Podfile
-h, --help output usage information"
-h, --help display help for command"
`;
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@

exports[`cli-command object 1`] = `
Object {
"action": [Function],
"description": "creates a React Native library module for one or more platforms",
"func": [Function],
"name": "create-library",
"options": Array [
Object {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
const func = require('../../../../../../../../lib/cli-command.js').func;
const action = require('../../../../../../../../lib/cli-command.js').action;

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

const options = { platforms: 'bogus' };

await func(args, null, options);
await action(args, options);

expect(mysnap).toMatchSnapshot();
});
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
const func = require('../../../../../../../../lib/cli-command.js').func;
const action = require('../../../../../../../../lib/cli-command.js').action;

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

const options = { platforms: '' };

await func(args, null, options);
await action(args, options);

expect(mysnap).toMatchSnapshot();
});
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
const func = require('../../../../../../../lib/cli-command.js').func;
const action = require('../../../../../../../lib/cli-command.js').action;

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

const config = 'bogus';

await func(args, config, {});
await action(args, {});

expect(mysnap).toMatchSnapshot();
});
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
const func = require('../../../../../../lib/cli-command.js').func;
const action = require('../../../../../../lib/cli-command.js').action;

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

const config = 'bogus';

const options = {
platforms: 'android,ios',
tvosEnabled: true,
Expand All @@ -31,6 +29,6 @@ test('create alice-bobbi module with explicit config options for Android & iOS',
license: 'ISC',
};

return func(args, config, options)
return action(args, options)
.then(() => { expect(mysnap).toMatchSnapshot(); });
});
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ const mockCommander = {
mockpushit({ parse: { argv } });
mockCommanderState.actionFunction.apply(
{ opts: () => ({ platforms: 'android' }) },
['test-package']);
[{ bogus: {} }, ['test-package']]);
},
help: () => {
throw new Error('help call not expected in this test');
Expand Down
8 changes: 4 additions & 4 deletions yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -1073,10 +1073,10 @@ combined-stream@^1.0.6, combined-stream@~1.0.6:
dependencies:
delayed-stream "~1.0.0"

commander@^3.0.1:
version "3.0.2"
resolved "https://registry.yarnpkg.com/commander/-/commander-3.0.2.tgz#6837c3fb677ad9933d1cfba42dd14d5117d6b39e"
integrity sha512-Gar0ASD4BDyKC4hl4DwHqDrmvjoxWKZigVnAbn5H1owvm4CxCPdb0HQDehwNYMJpla5+M2tPmPARzhtYuwpHow==
commander@^5.0.0:
version "5.0.0"
resolved "https://registry.yarnpkg.com/commander/-/commander-5.0.0.tgz#dbf1909b49e5044f8fdaf0adc809f0c0722bdfd0"
integrity sha512-JrDGPAKjMGSP1G0DUoaceEJ3DZgAfr/q6X7FVk4+U5KxUSKviYGM2k6zWkfyyBHy5rAtzgYJFa1ro2O9PtoxwQ==

commander@~4.1.0:
version "4.1.1"
Expand Down