feat: remove shrinkwrap.yaml when no deps left in package.json

This commit is contained in:
zkochan
2017-03-04 22:05:10 +02:00
parent ddc69abd9f
commit 7d48b9d07e
2 changed files with 23 additions and 1 deletions

View File

@@ -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 || {}

View File

@@ -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)