From cb9051b1ad86c7de11c2f5ce466b145dcbc54fe2 Mon Sep 17 00:00:00 2001 From: Zoltan Kochan Date: Mon, 26 Feb 2018 01:29:28 +0200 Subject: [PATCH] fix: should work when only current shrinkwrap.yaml is available --- src/index.ts | 1 + .../current-shrinkwrap-only/.gitignore | 1 + .../node_modules/.shrinkwrap.yaml | 27 +++++++++++++++++++ .../current-shrinkwrap-only/package.json | 8 ++++++ test/index.ts | 13 +++++++++ 5 files changed, 50 insertions(+) create mode 100644 test/fixtures/current-shrinkwrap-only/.gitignore create mode 100644 test/fixtures/current-shrinkwrap-only/node_modules/.shrinkwrap.yaml create mode 100644 test/fixtures/current-shrinkwrap-only/package.json diff --git a/src/index.ts b/src/index.ts index 74211cf5c8..ffc3aa122a 100644 --- a/src/index.ts +++ b/src/index.ts @@ -94,6 +94,7 @@ async function _outdated ( }, ): Promise { 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.') } diff --git a/test/fixtures/current-shrinkwrap-only/.gitignore b/test/fixtures/current-shrinkwrap-only/.gitignore new file mode 100644 index 0000000000..cf4bab9ddd --- /dev/null +++ b/test/fixtures/current-shrinkwrap-only/.gitignore @@ -0,0 +1 @@ +!node_modules diff --git a/test/fixtures/current-shrinkwrap-only/node_modules/.shrinkwrap.yaml b/test/fixtures/current-shrinkwrap-only/node_modules/.shrinkwrap.yaml new file mode 100644 index 0000000000..d1b2df33af --- /dev/null +++ b/test/fixtures/current-shrinkwrap-only/node_modules/.shrinkwrap.yaml @@ -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 diff --git a/test/fixtures/current-shrinkwrap-only/package.json b/test/fixtures/current-shrinkwrap-only/package.json new file mode 100644 index 0000000000..e3bf90b7d3 --- /dev/null +++ b/test/fixtures/current-shrinkwrap-only/package.json @@ -0,0 +1,8 @@ +{ + "name": "wanted-shrinkwrap", + "version": "1.0.0", + "dependencies": { + "is-negative": "^2.1.0", + "is-positive": "^3.1.0" + } +} diff --git a/test/index.ts b/test/index.ts index 6f8fd5a258..fefb49adbb 100644 --- a/test/index.ts +++ b/test/index.ts @@ -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() +})