Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 0 additions & 2 deletions lib/commands/edit.js
Original file line number Diff line number Diff line change
Expand Up @@ -33,8 +33,6 @@ class Edit extends BaseCommand {
static params = ['editor']
static ignoreImplicitWorkspace = false

// TODO
/* istanbul ignore next */
static async completion (opts, npm) {
return completion(npm, opts)
}
Expand Down
2 changes: 0 additions & 2 deletions lib/commands/explain.js
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,6 @@ class Explain extends ArboristWorkspaceCmd {

static ignoreImplicitWorkspace = false

// TODO
/* istanbul ignore next */
static async completion (opts, npm) {
const completion = require('../utils/installed-deep.js')
return completion(npm, opts)
Expand Down
2 changes: 0 additions & 2 deletions lib/commands/explore.js
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,6 @@ class Explore extends BaseCommand {
static params = ['shell']
static ignoreImplicitWorkspace = false

// TODO
/* istanbul ignore next */
static async completion (opts, npm) {
return completion(npm, opts)
}
Expand Down
2 changes: 0 additions & 2 deletions lib/commands/fund.js
Original file line number Diff line number Diff line change
Expand Up @@ -34,8 +34,6 @@ class Fund extends ArboristWorkspaceCmd {
return `${msg}\``
}

// TODO
/* istanbul ignore next */
static async completion (opts, npm) {
const completion = require('../utils/installed-deep.js')
return completion(npm, opts)
Expand Down
2 changes: 0 additions & 2 deletions lib/commands/get.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,6 @@ class Get extends BaseCommand {
static params = ['long']
static ignoreImplicitWorkspace = false

// TODO
/* istanbul ignore next */
static async completion (opts) {
const Config = Npm.cmd('config')
return Config.completion(opts)
Expand Down
2 changes: 0 additions & 2 deletions lib/commands/ls.js
Original file line number Diff line number Diff line change
Expand Up @@ -39,8 +39,6 @@ class LS extends ArboristWorkspaceCmd {
...super.params,
]

// TODO
/* istanbul ignore next */
static async completion (opts, npm) {
const completion = require('../utils/installed-deep.js')
return completion(npm, opts)
Expand Down
2 changes: 0 additions & 2 deletions lib/commands/rebuild.js
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,6 @@ class Rebuild extends ArboristWorkspaceCmd {

static usage = ['[<package-spec>] ...]']

// TODO
/* istanbul ignore next */
static async completion (opts, npm) {
const completion = require('../utils/installed-deep.js')
return completion(npm, opts)
Expand Down
2 changes: 0 additions & 2 deletions lib/commands/set.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,6 @@ class Set extends BaseCommand {
static params = ['global', 'location']
static ignoreImplicitWorkspace = false

// TODO
/* istanbul ignore next */
static async completion (opts) {
const Config = Npm.cmd('config')
return Config.completion(opts)
Expand Down
2 changes: 0 additions & 2 deletions lib/commands/uninstall.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,6 @@ class Uninstall extends ArboristWorkspaceCmd {
static usage = ['[<@scope>/]<pkg>...']
static ignoreImplicitWorkspace = false

// TODO
/* istanbul ignore next */
static async completion (opts, npm) {
return completion(npm, opts)
}
Expand Down
2 changes: 0 additions & 2 deletions lib/commands/update.js
Original file line number Diff line number Diff line change
Expand Up @@ -29,8 +29,6 @@ class Update extends ArboristWorkspaceCmd {

static usage = ['[<pkg>...]']

// TODO
/* istanbul ignore next */
static async completion (opts, npm) {
const completion = require('../utils/installed-deep.js')
return completion(npm, opts)
Expand Down
14 changes: 14 additions & 0 deletions test/lib/commands/edit.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,20 @@ const path = require('node:path')
const tspawk = require('../../fixtures/tspawk')
const { load: loadMockNpm } = require('../../fixtures/mock-npm')

t.test('completion', async t => {
const { edit } = await loadMockNpm(t, {
command: 'edit',
prefixDir: {
node_modules: {
foo: {},
bar: {},
},
},
})
const res = await edit.completion({ conf: { argv: { remain: ['npm', 'edit'] } } })
t.match(res, ['bar', 'foo'])
})

const spawk = tspawk(t)

const npmConfig = {
Expand Down
16 changes: 16 additions & 0 deletions test/lib/commands/explain.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,22 @@ const t = require('tap')
const { resolve } = require('node:path')
const mockNpm = require('../../fixtures/mock-npm.js')

t.test('completion', async t => {
const { explain } = await mockNpm(t, {
command: 'explain',
prefixDir: {
node_modules: {
foo: {
'package.json': JSON.stringify({ name: 'foo', version: '1.0.0' }),
},
},
'package.json': JSON.stringify({ name: 'project', version: '1.0.0' }),
},
})
const res = await explain.completion({ conf: { argv: { remain: ['npm', 'explain'] } } })
t.type(res, Array)
})

const mockExplain = async (t, opts) => {
const mock = await mockNpm(t, {
command: 'explain',
Expand Down
14 changes: 14 additions & 0 deletions test/lib/commands/explore.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,20 @@ const t = require('tap')
const mockNpm = require('../../fixtures/mock-npm')
const { cleanCwd } = require('../../fixtures/clean-snapshot')

t.test('completion', async t => {
const { explore } = await mockNpm(t, {
command: 'explore',
prefixDir: {
node_modules: {
foo: {},
bar: {},
},
},
})
const res = await explore.completion({ conf: { argv: { remain: ['npm', 'explore'] } } })
t.match(res, ['bar', 'foo'])
})

const mockExplore = async (t, exec, {
PJ_ERROR = null,
RUN_SCRIPT_ERROR = null,
Expand Down
16 changes: 16 additions & 0 deletions test/lib/commands/fund.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,22 @@
const t = require('tap')
const mockNpm = require('../../fixtures/mock-npm')

t.test('completion', async t => {
const { fund } = await mockNpm(t, {
command: 'fund',
prefixDir: {
node_modules: {
foo: {
'package.json': JSON.stringify({ name: 'foo', version: '1.0.0' }),
},
},
'package.json': JSON.stringify({ name: 'project', version: '1.0.0' }),
},
})
const res = await fund.completion({ conf: { argv: { remain: ['npm', 'fund'] } } })
t.type(res, Array)
})

const version = '1.0.0'

const funding = {
Expand Down
6 changes: 6 additions & 0 deletions test/lib/commands/get.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,12 @@
const t = require('tap')
const { load: loadMockNpm } = require('../../fixtures/mock-npm')

t.test('completion', async t => {
const { get } = await loadMockNpm(t, { command: 'get' })
const res = await get.completion({ conf: { argv: { remain: ['npm', 'get'] } } })
t.type(res, Array)
})

t.test('should retrieve values from config', async t => {
const name = 'editor'
const value = 'vigor'
Expand Down
16 changes: 16 additions & 0 deletions test/lib/commands/ls.js
Original file line number Diff line number Diff line change
Expand Up @@ -5285,3 +5285,19 @@ t.test('ls --package-lock-only', async t => {
})
})
})

t.test('completion', async t => {
const { ls } = await mockNpm(t, {
command: 'ls',
prefixDir: {
node_modules: {
foo: {
'package.json': JSON.stringify({ name: 'foo', version: '1.0.0' }),
},
},
'package.json': JSON.stringify({ name: 'project', version: '1.0.0' }),
},
})
const res = await ls.completion({ conf: { argv: { remain: ['npm', 'ls'] } } })
t.type(res, Array)
})
16 changes: 16 additions & 0 deletions test/lib/commands/rebuild.js
Original file line number Diff line number Diff line change
Expand Up @@ -205,3 +205,19 @@ t.test('global prefix', async t => {
'should output success msg'
)
})

t.test('completion', async t => {
const { rebuild } = await setupMockNpm(t, {
command: 'rebuild',
prefixDir: {
node_modules: {
foo: {
'package.json': JSON.stringify({ name: 'foo', version: '1.0.0' }),
},
},
'package.json': JSON.stringify({ name: 'project', version: '1.0.0' }),
},
})
const res = await rebuild.completion({ conf: { argv: { remain: ['npm', 'rebuild'] } } })
t.type(res, Array)
})
6 changes: 6 additions & 0 deletions test/lib/commands/set.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,12 @@ const mockNpm = require('../../fixtures/mock-npm')
const { join } = require('node:path')
const { cleanNewlines } = require('../../fixtures/clean-snapshot')

t.test('completion', async t => {
const { set } = await mockNpm(t, { command: 'set' })
const res = await set.completion({ conf: { argv: { remain: ['npm', 'set'] } } })
t.type(res, Array)
})

t.test('no args', async t => {
const { npm } = await mockNpm(t)
t.rejects(npm.exec('set', []), /Usage:/, 'prints usage')
Expand Down
14 changes: 14 additions & 0 deletions test/lib/commands/uninstall.js
Original file line number Diff line number Diff line change
Expand Up @@ -200,3 +200,17 @@ t.test('non ENOENT error reading from localPrefix package.json', async t => {
'should throw non ENOENT error'
)
})

t.test('completion', async t => {
const { uninstall } = await _mockNpm(t, {
command: 'uninstall',
prefixDir: {
node_modules: {
foo: {},
bar: {},
},
},
})
const res = await uninstall.completion({ conf: { argv: { remain: ['npm', 'uninstall'] } } })
t.match(res, ['bar', 'foo'])
})
16 changes: 16 additions & 0 deletions test/lib/commands/update.js
Original file line number Diff line number Diff line change
Expand Up @@ -79,3 +79,19 @@ t.test('update --global', async t => {
t.match(ctor.path, globalPrefix)
t.ok(ctor.path.startsWith(globalPrefix))
})

t.test('completion', async t => {
const { update } = await _mockNpm(t, {
command: 'update',
prefixDir: {
node_modules: {
foo: {
'package.json': JSON.stringify({ name: 'foo', version: '1.0.0' }),
},
},
'package.json': JSON.stringify({ name: 'project', version: '1.0.0' }),
},
})
const res = await update.completion({ conf: { argv: { remain: ['npm', 'update'] } } })
t.type(res, Array)
})
Loading