mirror of
https://github.com/pnpm/pnpm.git
synced 2026-05-18 22:02:53 -04:00
fix(uninstall): report updated package.json
This commit is contained in:
@@ -2,6 +2,7 @@ import loadJsonFile = require('load-json-file')
|
||||
import writePkg = require('write-pkg')
|
||||
import {DependenciesType, dependenciesTypes} from './getSaveType'
|
||||
import {PackageJson} from '@pnpm/types'
|
||||
import {packageJsonLogger} from './loggers'
|
||||
|
||||
export default async function (
|
||||
pkgJsonPath: string,
|
||||
@@ -29,5 +30,6 @@ export default async function (
|
||||
}
|
||||
|
||||
await writePkg(pkgJsonPath, packageJson)
|
||||
packageJsonLogger.debug({ updated: packageJson })
|
||||
return packageJson
|
||||
}
|
||||
|
||||
@@ -20,6 +20,7 @@ import {
|
||||
storePrune,
|
||||
RootLog,
|
||||
StatsLog,
|
||||
PackageJsonLog,
|
||||
} from 'supi'
|
||||
import thenify = require('thenify')
|
||||
import sinon = require('sinon')
|
||||
@@ -29,10 +30,22 @@ const ncp = thenify(ncpCB.ncp)
|
||||
test('uninstall package with no dependencies', async (t: tape.Test) => {
|
||||
const project = prepare(t)
|
||||
|
||||
const reporter = sinon.spy()
|
||||
await installPkgs(['is-negative@2.1.0'], await testDefaults({ save: true }))
|
||||
|
||||
const reporter = sinon.spy()
|
||||
await uninstall(['is-negative'], await testDefaults({ save: true, reporter }))
|
||||
|
||||
t.ok(reporter.calledWithMatch(<PackageJsonLog>{
|
||||
name: 'pnpm:package-json',
|
||||
level: 'debug',
|
||||
initial: {
|
||||
name: 'project',
|
||||
version: '0.0.0',
|
||||
dependencies: {
|
||||
'is-negative': '^2.1.0',
|
||||
},
|
||||
},
|
||||
}), 'initial package.json logged')
|
||||
t.ok(reporter.calledWithMatch(<StatsLog>{
|
||||
name: 'pnpm:stats',
|
||||
level: 'debug',
|
||||
@@ -47,6 +60,14 @@ test('uninstall package with no dependencies', async (t: tape.Test) => {
|
||||
dependencyType: 'prod',
|
||||
},
|
||||
}), 'removing root dependency reported')
|
||||
t.ok(reporter.calledWithMatch(<PackageJsonLog>{
|
||||
name: 'pnpm:package-json',
|
||||
level: 'debug',
|
||||
updated: {
|
||||
name: 'project',
|
||||
version: '0.0.0',
|
||||
},
|
||||
}), 'updated package.json logged')
|
||||
|
||||
// uninstall does not remove packages from store
|
||||
// even if they become unreferenced
|
||||
|
||||
Reference in New Issue
Block a user