Refactor of the cmd.js - Still a WIP, but looking for comments #73
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-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.