Nightwatch flags inspection during installation - #101
Conversation
|
|
||
| //Check the passed flags when installing Nightwatch and then suggest when undefined flag is been found. | ||
| if (argv[0] !== undefined) { | ||
| if ((argv[0] !== '--mobile') && (String(argv[0]) !== '--generate-config')) { |
There was a problem hiding this comment.
@olawoyinsamson You should use the options variable here instead of directly using argv. See minimist documentation for the difference between args and options here.
Also, your implementation is wrong, if you try running the tool locally with npm run create-nightwatch -- --mobile --generate-config, it will exit even when the flags passed are correct. Plus, you should not check for the flags like this (think in the lines of if we want to add more flags in the tool, how should we do it; we shouldn't need to make changes at multiple places throughout the code while doing so).
An implementation of what we're trying to achieve (give suggestions in case wrong flags are passed) is already present below in this file itself, so you should ideally make changes to that to use didYouMean instead of suggestSimilarOption, and exit the process in case wrong flags (or even arguments) are passed to the tool.
Signed-off-by: Samson Olawoyin <olawoyin.samson@outlook.com>
| import {NIGHTWATCH_TITLE, AVAILABLE_CONFIG_FLAGS} from './constants'; | ||
| import Logger from './logger'; | ||
| import minimist from 'minimist'; | ||
| import suggestSimilarOption from './utils/suggestSimilar'; |
There was a problem hiding this comment.
Please remove ./utils/suggestSimilar. Also, what's the motive behind this change?
Also, why not use didyoumean or didyoumean2?
There was a problem hiding this comment.
@vaibhavsingh97 thank you for your review, it was suggested that didyoumean library be used in place of the module suggestSimilarOption for suggesting Nightwatch flags when a wrong flags is been detected and then terminate the Nightwatch process. The Nightwatch issue is: #85. I will refactor the changes now with didyoumean2 because didyoumean do not support module implementation and then remove the suggestSimilarOption.
There was a problem hiding this comment.
@vaibhavsingh97 i trust you are doing very well today, i wanted to mentioned that i have updated this PR with your suggestions above and now the PR has also passed the required check but could you please help look at this when you have some moment.
Signed-off-by: Samson Olawoyin <olawoyin.samson@outlook.com>
This feature inspect the inputed flags (-- --mobile or -- --generate-config) when installing Nightwatch and then give suggestion on invalid flags detection and then terminate Nightwatch installation setup.