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

Refactor/refactor code to enable testing #52

Merged
merged 6 commits into from
Sep 6, 2022

Conversation

neodmy
Copy link
Contributor

@neodmy neodmy commented Aug 31, 2022

Main changes

  • 🔄 (refactor)

In order to enable unit and end-to-end testing, I propose to split the code into several parts:

  • The index.js has been simplified and acts as a dependency injector and the only point for error handling:
    • Retrieves the arguments from yargs
    • Uses a middleware to run some checks and transform certain arguments. For instance, the arguments passed to failOn might include a RegEx. These RegExs must be valid.
    • Execute the core logic by calling the licence-checker, which is now wrapped in a promise

Additional notes

(optional)

Context

Copy link
Member

@inigomarquinez inigomarquinez left a comment

Choose a reason for hiding this comment

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

Awesome refactor, @neodmy !

I've added some comments and questions.

Apart from that, perhaps we need to discuss where to place some functions. The code as you left it after the refactor looks very clean and organized. However, there is already a utils file, and we have methods both in the runner and utils files. So perhaps we can move all to one single file. What do you think?

src/runner.js Show resolved Hide resolved
src/runner.js Outdated Show resolved Hide resolved
index.js Show resolved Hide resolved
@neodmy
Copy link
Contributor Author

neodmy commented Sep 2, 2022

Awesome refactor, @neodmy !

I've added some comments and questions.

Apart from that, perhaps we need to discuss where to place some functions. The code as you left it after the refactor looks very clean and organized. However, there is already a utils file, and we have methods both in the runner and utils files. So perhaps we can move all to one single file. What do you think?

68747470733a2f2f6d65646961342e67697068792e636f6d2f6d656469612f6d586e4f394969575761726b492f67697068792e676966

Sure 👍

inigomarquinez
inigomarquinez previously approved these changes Sep 5, 2022
Copy link
Member

@inigomarquinez inigomarquinez left a comment

Choose a reason for hiding this comment

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

LGTM!

ardguezsoc
ardguezsoc previously approved these changes Sep 5, 2022
dustytrinkets
dustytrinkets previously approved these changes Sep 5, 2022
Copy link
Member

@inigomarquinez inigomarquinez left a comment

Choose a reason for hiding this comment

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

LGTM!

@inigomarquinez inigomarquinez merged commit ef00b66 into main Sep 6, 2022
@inigomarquinez inigomarquinez deleted the refactor/refactor-code-to-enable-testing branch September 6, 2022 14:21
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

4 participants