From 7d48b9d07eacdcb0f1f7a3caa1facd54c7ea90d8 Mon Sep 17 00:00:00 2001 From: zkochan Date: Sat, 4 Mar 2017 22:05:10 +0200 Subject: [PATCH] feat: remove shrinkwrap.yaml when no deps left in package.json --- src/api/install.ts | 2 +- test/shrinkwrap.ts | 22 ++++++++++++++++++++++ 2 files changed, 23 insertions(+), 1 deletion(-) diff --git a/src/api/install.ts b/src/api/install.ts index 686480287c..5a5aad401d 100644 --- a/src/api/install.ts +++ b/src/api/install.ts @@ -148,7 +148,7 @@ async function installInContext (installType: string, packagesToInstall: Depende } } - if (pkgs && pkgs.length && newPkg) { + if (newPkg) { ctx.shrinkwrap.dependencies = ctx.shrinkwrap.dependencies || {} const deps = newPkg.dependencies || {} diff --git a/test/shrinkwrap.ts b/test/shrinkwrap.ts index e57ae86a37..8f718399b9 100644 --- a/test/shrinkwrap.ts +++ b/test/shrinkwrap.ts @@ -85,6 +85,28 @@ test('shrinkwrap not created when no deps in package.json', async t => { t.ok(!await project.loadShrinkwrap(), 'shrinkwrap file not created') }) +test('shrinkwrap removed when no deps in package.json', async t => { + const project = prepare(t) + + await writeYamlFile('shrinkwrap.yaml', { + version: 1, + dependencies: { + 'is-negative@2.1.0': 'localhost+4873/is-negative/2.1.0', + }, + packages: { + 'localhost+4873/is-negative/2.1.0': { + resolution: { + tarball: 'http://localhost:4873/is-negative/-/is-negative-2.1.0.tgz', + }, + }, + }, + }) + + await install(testDefaults()) + + t.ok(!await project.loadShrinkwrap(), 'shrinkwrap file removed') +}) + test('respects shrinkwrap.yaml for top dependencies', async t => { const project = prepare(t)