-
Notifications
You must be signed in to change notification settings - Fork 3.2k
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
fix: Add check to pkg command to deal with empty values #6902
Merged
Merged
Changes from 10 commits
Commits
Show all changes
14 commits
Select commit
Hold shift + click to select a range
8924565
Discern result key from overlapping value
NeonArray 61f7266
Add test for multiple args and empty value
NeonArray a1963b0
Revert overlap check
NeonArray 7e8639f
Return empty string if prop exists and undef
NeonArray 49e9e44
Modify error message for accuracy
NeonArray c654451
Add view test for empty value
NeonArray e808248
Add empty property to yellow
NeonArray 6bf0fff
Remove version tag from test
NeonArray d017ecb
Update view snapshot
NeonArray 4ed95aa
Check for explicit boolean value
NeonArray 8fb8ddf
Return value instead of _data[k]
NeonArray 6fdc97f
Simplify check to only return undefined
NeonArray 1c71e20
Remove temporary var value
NeonArray b4ea660
Replace undefined check with hasOwn
NeonArray File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains 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
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -315,6 +315,10 @@ maintainers[0].name = 'claudia' | |
maintainers[1].name = 'isaacs' | ||
` | ||
|
||
exports[`test/lib/commands/view.js TAP specific field names fields with empty values > must match snapshot 1`] = ` | ||
|
||
` | ||
|
||
exports[`test/lib/commands/view.js TAP specific field names maintainers with email > must match snapshot 1`] = ` | ||
maintainers = [ | ||
{ name: 'claudia', email: '[email protected]', twitter: 'cyellow' }, | ||
|
This file contains 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
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -101,6 +101,7 @@ const packument = (nv, opts) => { | |
email: '[email protected]', | ||
twitter: 'foo', | ||
}, | ||
empty: '', | ||
readme: 'a very useful readme', | ||
versions: { | ||
'1.0.0': { | ||
|
@@ -425,6 +426,11 @@ t.test('specific field names', async t => { | |
await view.exec(['[email protected]', 'maintainers.name']) | ||
t.matchSnapshot(outputs.join('\n')) | ||
}) | ||
|
||
t.test('fields with empty values', async t => { | ||
await view.exec(['yellow', 'empty']) | ||
t.matchSnapshot(outputs.join('\n')) | ||
}) | ||
}) | ||
|
||
t.test('throw error if global mode', async t => { | ||
|
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.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
if
value === undefined
andvalue = _data[k]
then returning_data[k]
would return undefined anyways. Not sure what this check gains us.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You're right, I did overcomplicate that. The undefined check is needed since other functionality/tests expect it to be returned and not just set to
_data
.I simplified it so now it only returns undefined, else just sets up
_data = value
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
> The undefined check is needed since other functionality/tests expect it to be returned and not just set to _data.Can you show me where this is happening? That still seems very counterintuitive.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
oooooh I see it now. we're not returning otherwise. My bad!
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
OK I think we're getting somewhere. I think this check should be JUST a
hasOwn
, and if that's false we return undefined. Otherwise we let it fall through.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
That works, change has been made