-
Notifications
You must be signed in to change notification settings - Fork 3.2k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix: account for new npm-package-arg behavior
`npm`, `npm@`, and `npm@*` are all now the same spec
- Loading branch information
1 parent
de2d33f
commit 1afe5ba
Showing
19 changed files
with
91 additions
and
91 deletions.
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
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
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
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 |
---|---|---|
|
@@ -216,7 +216,7 @@ t.test('single arg', t => { | |
}) | ||
|
||
libnpmdiff = async ([a, b], opts) => { | ||
t.equal(a, 'simple-output@latest', 'should forward single spec') | ||
t.equal(a, 'simple-output@*', 'should forward single spec') | ||
t.equal(b, `file:${path}`, 'should compare to cwd') | ||
t.match(opts, npm.flatOptions, 'should forward flat options') | ||
} | ||
|
@@ -460,7 +460,7 @@ t.test('single arg', t => { | |
} | ||
}, | ||
libnpmdiff: async ([a, b], opts) => { | ||
t.equal(a, 'lorem@latest', 'should target latest version of pkg name') | ||
t.equal(a, 'lorem@*', 'should target any version of pkg name') | ||
t.equal(b, `file:${path}`, 'should target current cwd') | ||
}, | ||
}) | ||
|
@@ -479,7 +479,7 @@ t.test('single arg', t => { | |
'package.json': JSON.stringify({ version: '1.0.0' }), | ||
}) | ||
libnpmdiff = async ([a, b], opts) => { | ||
t.equal(a, 'bar@latest', 'should target latest tag of name') | ||
t.equal(a, 'bar@*', 'should target any version of pkg name') | ||
t.equal(b, `file:${path}`, 'should compare to cwd') | ||
} | ||
|
||
|
@@ -493,7 +493,7 @@ t.test('single arg', t => { | |
t.plan(2) | ||
|
||
libnpmdiff = async ([a, b], opts) => { | ||
t.equal(a, 'foo@latest', 'should target latest tag of name') | ||
t.equal(a, 'foo@*', 'should target any version of pkg name') | ||
t.equal(b, `file:${fooPath}`, 'should compare to cwd') | ||
} | ||
|
||
|
@@ -592,7 +592,7 @@ t.test('first arg is a qualified spec', t => { | |
|
||
libnpmdiff = async ([a, b], opts) => { | ||
t.equal(a, '[email protected]', 'should set expected first spec') | ||
t.equal(b, 'bar-fork@latest', 'should target latest tag if not a dep') | ||
t.equal(b, 'bar-fork@*', 'should target any version if not a dep') | ||
} | ||
|
||
config.diff = ['[email protected]', 'bar-fork'] | ||
|
@@ -753,7 +753,7 @@ t.test('first arg is a known dependency name', async t => { | |
`bar@file:${resolve(path, 'node_modules/bar')}`, | ||
'should target local node_modules pkg' | ||
) | ||
t.equal(b, 'bar-fork@latest', 'should set expected second spec') | ||
t.equal(b, 'bar-fork@*', 'should set expected second spec') | ||
} | ||
|
||
npm.prefix = path | ||
|
@@ -840,7 +840,7 @@ t.test('first arg is a valid semver range', t => { | |
|
||
libnpmdiff = async ([a, b], opts) => { | ||
t.equal(a, '[email protected]', 'should use name from second arg') | ||
t.equal(b, 'bar@latest', 'should compare against latest tag') | ||
t.equal(b, 'bar@*', 'should compare against any version') | ||
} | ||
|
||
config.diff = ['1.0.0', 'bar'] | ||
|
@@ -884,7 +884,7 @@ t.test('first arg is an unknown dependency name', t => { | |
t.plan(4) | ||
|
||
libnpmdiff = async ([a, b], opts) => { | ||
t.equal(a, 'bar@latest', 'should set expected first spec') | ||
t.equal(a, 'bar@*', 'should set expected first spec') | ||
t.equal(b, '[email protected]', 'should set expected second spec') | ||
t.match(opts, npm.flatOptions, 'should forward flat options') | ||
t.match(opts, { where: fooPath }, 'should forward pacote options') | ||
|
@@ -919,7 +919,7 @@ t.test('first arg is an unknown dependency name', t => { | |
}) | ||
|
||
libnpmdiff = async ([a, b], opts) => { | ||
t.equal(a, 'bar-fork@latest', 'should use latest tag') | ||
t.equal(a, 'bar-fork@*', 'should use any version') | ||
t.equal( | ||
b, | ||
`bar@file:${resolve(path, 'node_modules/bar')}`, | ||
|
@@ -940,7 +940,7 @@ t.test('first arg is an unknown dependency name', t => { | |
t.plan(2) | ||
|
||
libnpmdiff = async ([a, b], opts) => { | ||
t.equal(a, 'bar@latest', 'should use latest tag') | ||
t.equal(a, 'bar@*', 'should use any version') | ||
t.equal(b, 'bar@^1.0.0', 'should use name from first arg') | ||
} | ||
|
||
|
@@ -956,8 +956,8 @@ t.test('first arg is an unknown dependency name', t => { | |
t.plan(2) | ||
|
||
libnpmdiff = async ([a, b], opts) => { | ||
t.equal(a, 'bar@latest', 'should use latest tag') | ||
t.equal(b, 'bar-fork@latest', 'should use latest tag') | ||
t.equal(a, 'bar@*', 'should use any version') | ||
t.equal(b, 'bar-fork@*', 'should use any version') | ||
} | ||
|
||
config.diff = ['bar', 'bar-fork'] | ||
|
@@ -973,8 +973,8 @@ t.test('first arg is an unknown dependency name', t => { | |
|
||
const path = t.testdir({}) | ||
libnpmdiff = async ([a, b], opts) => { | ||
t.equal(a, 'bar@latest', 'should use latest tag') | ||
t.equal(b, 'bar-fork@latest', 'should use latest tag') | ||
t.equal(a, 'bar@*', 'should use any version') | ||
t.equal(b, 'bar-fork@*', 'should use any version') | ||
} | ||
|
||
config.diff = ['bar', 'bar-fork'] | ||
|
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
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
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
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 |
---|---|---|
|
@@ -120,13 +120,13 @@ class Results { | |
this.#pendingCombinator = combinators[String(this.currentAstNode)] | ||
} | ||
|
||
// name selectors (i.e. #foo, #[email protected]) | ||
// name selectors (i.e. #foo) | ||
// css calls this id, we interpret it as name | ||
idType () { | ||
const spec = npa(this.currentAstNode.value) | ||
const name = this.currentAstNode.value | ||
const nextResults = this.initialItems.filter(node => | ||
(node.name === spec.name || node.package.name === spec.name) && | ||
(semver.satisfies(node.version, spec.fetchSpec) || !spec.rawSpec)) | ||
(name === node.name) || (name === node.package.name) | ||
) | ||
this.processPendingCombinator(nextResults) | ||
} | ||
|
||
|
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
Oops, something went wrong.