A RetroSearch Logo

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

Search Query:

Showing content from https://github.com/npm/cli/commit/780afc50e3a345feb1871a28e33fa48235bc3bd5 below:

display if any of multiple attributes exist (#7855) · npm/cli@780afc5 · GitHub

File tree Expand file treeCollapse file tree 2 files changed

+23

-3

lines changed

Filter options

Expand file treeCollapse file tree 2 files changed

+23

-3

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

@@ -63,12 +63,12 @@ class Pkg extends BaseCommand {

63 63 64 64

if (args.length) {

65 65

result = new Queryable(result).query(args)

66 -

// in case there's only a single result from the query

67 -

// just prints that one element to stdout

66 +

// in case there's only a single argument and a single result from the query

67 +

// just prints that one element to stdout.

68 68

// TODO(BREAKING_CHANGE): much like other places where we unwrap single

69 69

// item arrays this should go away. it makes the behavior unknown for users

70 70

// who don't already know the shape of the data.

71 -

if (Object.keys(result).length === 1) {

71 +

if (Object.keys(result).length === 1 && args.length === 1) {

72 72

result = result[args]

73 73

}

74 74

}

Original file line number Diff line number Diff line change

@@ -108,6 +108,26 @@ t.test('get multiple arg', async t => {

108 108

)

109 109

})

110 110 111 +

t.test('get multiple arg with only one arg existing', async t => {

112 +

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

113 +

prefixDir: {

114 +

'package.json': JSON.stringify({

115 +

name: 'foo',

116 +

}),

117 +

},

118 +

})

119 + 120 +

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

121 + 122 +

t.strictSame(

123 +

JSON.parse(OUTPUT()),

124 +

{

125 +

name: 'foo',

126 +

},

127 +

'should print retrieved package.json field'

128 +

)

129 +

})

130 + 111 131

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

112 132

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

113 133

prefixDir: {

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