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

Fix error message in case of missing name #305

Closed
brodycj opened this issue Apr 5, 2020 · 0 comments · Fixed by #306
Closed

Fix error message in case of missing name #305

brodycj opened this issue Apr 5, 2020 · 0 comments · Fixed by #306
Assignees
Labels
bug Something isn't working

Comments

@brodycj
Copy link
Owner

brodycj commented Apr 5, 2020

While testing something else in my work area I mistakenly tried the following command with the module package name missing in the master branch (at 4f4c563):

./bin/cli.js --generate-example --example-react-native-version react-native@0.60

which is equivalent to the following command with global installation:

create-react-native-module --generate-example --example-react-native-version react-native@0.60

It gave me the following output:

/Users/brodybits/dev/create-react-native-module/lib/cli-command.js:44
    const name = args[0];
                     ^

TypeError: Cannot read property '0' of undefined
    at Object.action (/Users/brodybits/dev/create-react-native-module/lib/cli-command.js:44:22)
    at Command.programAction (/Users/brodybits/dev/create-react-native-module/lib/cli-program.js:17:13)
    at Command.listener [as _actionHandler] (/Users/brodybits/dev/create-react-native-module/node_modules/commander/index.js:408:31)
    at Command._parseCommand (/Users/brodybits/dev/create-react-native-module/node_modules/commander/index.js:909:14)
    at Command.parse (/Users/brodybits/dev/create-react-native-module/node_modules/commander/index.js:712:10)
    at Object.<anonymous> (/Users/brodybits/dev/create-react-native-module/lib/cli-program.js:32:9)
    at Module._compile (internal/modules/cjs/loader.js:1158:30)
    at Object.Module._extensions..js (internal/modules/cjs/loader.js:1178:10)
    at Module.load (internal/modules/cjs/loader.js:1002:32)
    at Function.Module._load (internal/modules/cjs/loader.js:901:14)

At the recent 0.16.0 tag it would give me the following output:

    throw new TypeError("Please write your library's name");
    ^

TypeError: Please write your library's name
    at module.exports (/Users/brodybits/dev/create-react-native-module/lib/normalized-options.js:16:11)
    at Object.func (/Users/brodybits/dev/create-react-native-module/lib/cli-command.js:56:27)
    at Command.runAction (/Users/brodybits/dev/create-react-native-module/lib/cli-program.js:14:13)
    at Command.listener (/Users/brodybits/dev/create-react-native-module/node_modules/commander/index.js:291:8)
    at Command.emit (events.js:311:20)
    at Command.parseArgs (/Users/brodybits/dev/create-react-native-module/node_modules/commander/index.js:686:12)
    at Command.parse (/Users/brodybits/dev/create-react-native-module/node_modules/commander/index.js:459:21)
    at Object.<anonymous> (/Users/brodybits/dev/create-react-native-module/lib/cli-program.js:29:9)
    at Module._compile (internal/modules/cjs/loader.js:1158:30)
    at Object.Module._extensions..js (internal/modules/cjs/loader.js:1178:10)

P.S. Part of the cause is that this case was not properly covered by unit or integration testing.

@brodycj brodycj added the bug Something isn't working label Apr 5, 2020
@brodycj brodycj self-assigned this Apr 5, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant