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

[TIMOB-17227] CLI: Passing empty option value, building the project returns Error #5983

Merged
merged 3 commits into from Aug 29, 2014

Conversation

feons
Copy link
Contributor

@feons feons commented Aug 25, 2014

@@ -96,6 +96,18 @@ exports.config = function (logger, config, cli) {
'project-dir': {
abbr: 'd',
callback: function (projectDir) {
if (typeof projectDir === 'boolean' || projectDir === '') {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think we can get rid of the typeof projectDir === 'boolean'.

@feons
Copy link
Contributor Author

feons commented Aug 29, 2014

PR updated.

projectDir = conf.options['project-dir'].default;
if (!fs.existsSync(path.join(projectDir, 'tiapp.xml'))) {
logger.error(__('Invalid project directory "%s" because tiapp.xml not found', projectDir) + '\n');
process.exit(1);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Instead of logging the error and exiting, instead replace both lines with

return;

It's sorta complicated, but callback() is fired with an option has a value set and callback() can return a modified value. An empty string projectDir is passed in and we are modifying it by returning undefined. Internally this sets cli.argv['project-dir'] to undefined and the CLI's validation system will proceed to prompt for the project directory.

This is more elegant and consistent. Sorry I didn't think of it sooner.

@feons
Copy link
Contributor Author

feons commented Aug 29, 2014

It's a good idea! Updated PR.

@cb1kenobi
Copy link
Contributor

Code reviewed and tested. APPROVED!

cb1kenobi added a commit that referenced this pull request Aug 29, 2014
[TIMOB-17227] CLI: Passing empty option value, building the project returns Error
@cb1kenobi cb1kenobi merged commit 591db5c into tidev:master Aug 29, 2014
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants