fix: should work when only current shrinkwrap.yaml is available

This commit is contained in:
Zoltan Kochan
2018-02-26 01:29:28 +02:00
parent eeccd45011
commit cb9051b1ad
5 changed files with 50 additions and 0 deletions

View File

@@ -94,6 +94,7 @@ async function _outdated (
},
): Promise<OutdatedPackage[]> {
const wantedShrinkwrap = await readWantedShrinkwrap(pkgPath, {ignoreIncompatible: false})
|| await readCurrentShrinkwrap(pkgPath, {ignoreIncompatible: false})
if (!wantedShrinkwrap) {
throw new Error('No shrinkwrapfile in this directory. Run `pnpm install` to generate one.')
}

View File

@@ -0,0 +1 @@
!node_modules

View File

@@ -0,0 +1,27 @@
dependencies:
is-negative: 1.1.0
is-positive: 3.1.0
from-github: github.com/blabla/from-github/d5f8d5500f7faf593d32e134c1b0043ff69151b3
from-github-2: github.com/blabla/from-github-2/d5f8d5500f7faf593d32e134c1b0043ff69151b3
packages:
/is-negative/1.1.0:
resolution:
integrity: sha1-8Nhjd6oVpkw0lh84rCqb4rQKEYc=
/is-positive/3.1.0:
resolution:
integrity: sha1-hX21hKG6XRyymAUn/DtsQ103sP0=
github.com/blabla/from-github/d5f8d5500f7faf593d32e134c1b0043ff69151b3:
name: from-github
version: 1.0.0
resolution:
tarball: 'https://codeload.github.com/blabla/from-github/tar.gz/d5f8d5500f7faf593d32e134c1b0043ff69151b3'
github.com/blabla/from-github-2/d5f8d5500f7faf593d32e134c1b0043ff69151b3:
name: from-github-2
version: 1.0.0
resolution:
tarball: 'https://codeload.github.com/blabla/from-github-2/tar.gz/d5f8d5500f7faf593d32e134c1b0043ff69151b3'
registry: 'https://registry.npmjs.org/'
shrinkwrapVersion: 3
specifiers:
is-negative: ^2.1.0
is-positive: ^3.1.0

View File

@@ -0,0 +1,8 @@
{
"name": "wanted-shrinkwrap",
"version": "1.0.0",
"dependencies": {
"is-negative": "^2.1.0",
"is-positive": "^3.1.0"
}
}

View File

@@ -75,3 +75,16 @@ test('forPackages()', async (t) => {
])
t.end()
})
test('outdated() when only current shrinkwrap is present', async (t) => {
const outdatedPkgs = await outdated('current-shrinkwrap-only', outdatedOpts)
t.deepEqual(outdatedPkgs, [
{
current: '1.1.0',
latest: '2.1.0',
packageName: 'is-negative',
wanted: '1.1.0',
},
])
t.end()
})