A RetroSearch Logo

Home - News ( United States | United Kingdom | Italy | Germany ) - Football scores

Search Query:

Showing content from https://github.com/npm/cli/commit/35c92fec3d053d303cc8057faa0ff4fe6e7cdc8a below:

Add check to pkg command to deal with empty values (#6902) · npm/cli@35c92fe · GitHub

File tree Expand file treeCollapse file tree 4 files changed

+55

-5

lines changed

Filter options

Expand file treeCollapse file tree 4 files changed

+55

-5

lines changed Original file line number Diff line number Diff line change

@@ -111,13 +111,9 @@ const getter = ({ data, key }) => {

111 111

}, {})

112 112

return _data

113 113

} else {

114 -

// if can't find any more values, it means it's just over

115 -

// and there's nothing to return

116 -

if (!_data[k]) {

114 +

if (!Object.hasOwn(_data, k)) {

117 115

return undefined

118 116

}

119 - 120 -

// otherwise sets the next value

121 117

_data = _data[k]

122 118

}

123 119 Original file line number Diff line number Diff line change

@@ -315,6 +315,10 @@ maintainers[0].name = 'claudia'

315 315

maintainers[1].name = 'isaacs'

316 316

`

317 317 318 +

exports[`test/lib/commands/view.js TAP specific field names fields with empty values > must match snapshot 1`] = `

319 + 320 +

`

321 + 318 322

exports[`test/lib/commands/view.js TAP specific field names maintainers with email > must match snapshot 1`] = `

319 323

maintainers = [

320 324

{ name: 'claudia', email: 'c@yellow.com', twitter: 'cyellow' },

Original file line number Diff line number Diff line change

@@ -83,6 +83,50 @@ t.test('get single arg', async t => {

83 83

)

84 84

})

85 85 86 +

t.test('get multiple arg', async t => {

87 +

const { pkg, OUTPUT } = await mockNpm(t, {

88 +

prefixDir: {

89 +

'package.json': JSON.stringify({

90 +

name: 'foo',

91 +

version: '1.1.1',

92 +

}),

93 +

},

94 +

})

95 + 96 +

await pkg('get', 'name', 'version')

97 + 98 +

t.strictSame(

99 +

JSON.parse(OUTPUT()),

100 +

{

101 +

name: 'foo',

102 +

version: '1.1.1',

103 +

},

104 +

'should print retrieved package.json field'

105 +

)

106 +

})

107 + 108 +

t.test('get multiple arg with empty value', async t => {

109 +

const { pkg, OUTPUT } = await mockNpm(t, {

110 +

prefixDir: {

111 +

'package.json': JSON.stringify({

112 +

name: 'foo',

113 +

author: '',

114 +

}),

115 +

},

116 +

})

117 + 118 +

await pkg('get', 'name', 'author')

119 + 120 +

t.strictSame(

121 +

JSON.parse(OUTPUT()),

122 +

{

123 +

name: 'foo',

124 +

author: '',

125 +

},

126 +

'should print retrieved package.json field regardless of empty value'

127 +

)

128 +

})

129 + 86 130

t.test('get nested arg', async t => {

87 131

const { pkg, OUTPUT } = await mockNpm(t, {

88 132

prefixDir: {

Original file line number Diff line number Diff line change

@@ -101,6 +101,7 @@ const packument = (nv, opts) => {

101 101

email: 'foo@yellow.com',

102 102

twitter: 'foo',

103 103

},

104 +

empty: '',

104 105

readme: 'a very useful readme',

105 106

versions: {

106 107

'1.0.0': {

@@ -425,6 +426,11 @@ t.test('specific field names', async t => {

425 426

await view.exec(['yellow@1.x.x', 'maintainers.name'])

426 427

t.matchSnapshot(outputs.join('\n'))

427 428

})

429 + 430 +

t.test('fields with empty values', async t => {

431 +

await view.exec(['yellow', 'empty'])

432 +

t.matchSnapshot(outputs.join('\n'))

433 +

})

428 434

})

429 435 430 436

t.test('throw error if global mode', async t => {

You can’t perform that action at this time.


RetroSearch is an open source project built by @garambo | Open a GitHub Issue

Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo

HTML: 3.2 | Encoding: UTF-8 | Version: 0.7.4