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

Nightwatch flags inspection during installation #101

Open
wants to merge 2 commits into
base: main
Choose a base branch
from
Open
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
59 changes: 59 additions & 0 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,7 @@
"@nightwatch/setup-tools": "^3.3.1",
"ansi-colors": "^4.1.3",
"axios": "^0.27.2",
"didyoumean2": "^6.0.1",
"inquirer": "^8.2.4",
"minimist": "^1.2.6"
},
Expand Down
12 changes: 6 additions & 6 deletions src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ import {NightwatchInitiator} from '@nightwatch/setup-tools';
import {NIGHTWATCH_TITLE, AVAILABLE_CONFIG_FLAGS} from './constants';
import Logger from './logger';
import minimist from 'minimist';
import suggestSimilarOption from './utils/suggestSimilar';
Copy link
Member

Choose a reason for hiding this comment

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

Please remove ./utils/suggestSimilar. Also, what's the motive behind this change?
Also, why not use didyoumean or didyoumean2?

Copy link
Author

@samson-olawoyin samson-olawoyin Mar 13, 2024

Choose a reason for hiding this comment

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

@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.

Copy link
Author

Choose a reason for hiding this comment

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

@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.

import DidYouMean from 'didyoumean2';
import {isNodeProject} from './utils';
import {CURRENT_VERSION} from './utils/version';
import axios, {AxiosResponse} from 'axios';
Expand All @@ -34,12 +34,12 @@ export const run = async () => {
const wrongUserFlags = Object.keys(options).filter((word) => !AVAILABLE_CONFIG_FLAGS.includes(word));

if (wrongUserFlags.length > 0) {
const findAndSuggestSimilarOption = suggestSimilarOption(wrongUserFlags[0], AVAILABLE_CONFIG_FLAGS);
if (findAndSuggestSimilarOption !== '') {
Logger.error(`error: unknown option '${wrongUserFlags[0]}'${findAndSuggestSimilarOption}`);
const findAndSuggestSimilarOption = DidYouMean(wrongUserFlags[0], AVAILABLE_CONFIG_FLAGS);
const result = `Flag ${colors.red('--'+wrongUserFlags[0])} is not valid, did you mean ${colors.green('--'+findAndSuggestSimilarOption)}`;
Logger.error(result);

return;
}
// Exit Nightwatch setup process
process.exit(0);
}

let rootDir = path.resolve(process.cwd(), args[0] || '');
Expand Down
Loading