-
Notifications
You must be signed in to change notification settings - Fork 50
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 of the cmd.js - Still a WIP, but looking for comments #73
Conversation
squash: add more comments squash: add more comments
* This moves the --list-subsystems command up before the creation of the Validator, since it doesn't need that to happen
* This moves the function that loads the commit, from either a 'git show' or from a url, into the util module * This is for cleaning up the main cmd.js file which should only really have logic related to the commands
* This also adds the proxyquire and nock modules as dev dependencies
* move validate-metadata logic to utils for easier testing
* This moves the tap logic out of cmd.js and into a separate function in utils
477bd9a
to
b31953f
Compare
Codecov Report
@@ Coverage Diff @@
## master #73 +/- ##
=========================================
+ Coverage 57.14% 60.04% +2.9%
=========================================
Files 18 18
Lines 448 458 +10
=========================================
+ Hits 256 275 +19
+ Misses 192 183 -9
Continue to review full report at Codecov.
|
* This adds a callback function to both the validate-metadata and tap functions. * it also moves the process.exitCode assignment back into the cmd.js instead of the in the actual util module function * This will make testing those indiviual functions eaiser. * Another added benefit is if at some point a programmable API was to be created, we just want to return a code instead of assigning it to the process.exitCode
This refactor and PR are getting a little big. I think i might be able to break it up into smaller chunks. I'm going to close this and re-open another PR |
This PR is a work in progress to discuss the refactor discussed in #71 . The goal is to refactor the cmd.js file to not be cluttered with the actual logic of what a command does, which should help in being able to test it easier.
I've tried to keep the commits logically separated.
In the first commit, I've just added comments on what is actually happening. This was more for me to understand what is going on where.
The second commit just moves the logic for the
--list-subsystem
flag up a little in the code. not really a functional change, but more for style.Commits 3 and 4 are related to moving the load and loadPatch functions from the cmd.js file to the utils module. Moving them into the utils module, and exporting them, i was able to write tests for them as standalone functions. It also adds 2 new dev dependecies, proxyquire and nock.
The next 2 commits are related to moving the logic for the
--validate-metadata
and--tap
commands out, and into the utils module. Moving the logic out into its own function, i have to pass in aValidator
object, which will make it easier to mock and testI still need to write tests for these 2 functions, but I think now it will be easier to do so.
I just wanted to start this PR to have a discussion if what i'm doing and suggesting makes sense.