Refactor of the cmd.js - Still a WIP, but looking for comments#73
Closed
lholmquist wants to merge 7 commits intonodejs:masterfrom
Closed
Refactor of the cmd.js - Still a WIP, but looking for comments#73lholmquist wants to merge 7 commits intonodejs:masterfrom
lholmquist wants to merge 7 commits intonodejs:masterfrom
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
Contributor
Author
|
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 file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
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-subsystemflag 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-metadataand--tapcommands out, and into the utils module. Moving the logic out into its own function, i have to pass in aValidatorobject, 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.