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
Conversation
@@ -96,6 +96,18 @@ exports.config = function (logger, config, cli) { | |||
'project-dir': { | |||
abbr: 'd', | |||
callback: function (projectDir) { | |||
if (typeof projectDir === 'boolean' || projectDir === '') { |
There was a problem hiding this comment.
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'
.
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); |
There was a problem hiding this comment.
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.
It's a good idea! Updated PR. |
Code reviewed and tested. APPROVED! |
[TIMOB-17227] CLI: Passing empty option value, building the project returns Error
For https://jira.appcelerator.org/browse/TIMOB-17227