A RetroSearch Logo

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

Search Query:

Showing content from https://github.com/npm/cli/commit/78b5a6fa9cd103bb80a25957ddfcb5832bc1f937 below:

correctly handle scenario where prefix is the cwd (#8269) · npm/cli@78b5a6f · GitHub

File tree Expand file treeCollapse file tree 3 files changed

+23

-3

lines changed

Filter options

Expand file treeCollapse file tree 3 files changed

+23

-3

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

@@ -127,7 +127,7 @@ class Install extends ArboristWorkspaceCmd {

127 127

args = args.filter(a => resolve(a) !== this.npm.prefix)

128 128 129 129

// `npm i -g` => "install this package globally"

130 -

if (where === globalTop && !args.length) {

130 +

if (isGlobalInstall && !args.length) {

131 131

args = ['.']

132 132

}

133 133 Original file line number Diff line number Diff line change

@@ -107,6 +107,7 @@ const setupMockNpm = async (t, {

107 107

exec = null, // optionally exec the command before returning

108 108

// test dirs

109 109

prefixDir = {},

110 +

prefixOverride = null, // sets global and local prefix to this, the same as the `--prefix` flag

110 111

homeDir = {},

111 112

cacheDir = {},

112 113

globalPrefixDir = { node_modules: {} },

@@ -170,9 +171,9 @@ const setupMockNpm = async (t, {

170 171 171 172

const dirs = {

172 173

testdir: dir,

173 -

prefix: path.join(dir, 'prefix'),

174 +

prefix: prefixOverride ?? path.join(dir, 'prefix'),

174 175

cache: path.join(dir, 'cache'),

175 -

globalPrefix: path.join(dir, 'global'),

176 +

globalPrefix: prefixOverride ?? path.join(dir, 'global'),

176 177

home: path.join(dir, 'home'),

177 178

other: path.join(dir, 'other'),

178 179

}

Original file line number Diff line number Diff line change

@@ -126,6 +126,25 @@ t.test('exec commands', async t => {

126 126

await npm.exec('install')

127 127

})

128 128 129 +

await t.test('should not self-install package if prefix is the same as CWD', async t => {

130 +

let REIFY_CALLED_WITH = null

131 +

const { npm } = await loadMockNpm(t, {

132 +

mocks: {

133 +

'{LIB}/utils/reify-finish.js': async () => {},

134 +

'@npmcli/run-script': () => {},

135 +

'@npmcli/arborist': function () {

136 +

this.reify = (opts) => {

137 +

REIFY_CALLED_WITH = opts

138 +

}

139 +

},

140 +

},

141 +

prefixOverride: process.cwd(),

142 +

})

143 + 144 +

await npm.exec('install')

145 +

t.equal(REIFY_CALLED_WITH.add.length, 0, 'did not install current directory as a dependency')

146 +

})

147 + 129 148

await t.test('should not install invalid global package name', async t => {

130 149

const { npm } = await loadMockNpm(t, {

131 150

config: {

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