feat: change the format of skipped optional dep log

This commit is contained in:
Zoltan Kochan
2018-05-07 22:23:21 +03:00
parent 74d2ae74ce
commit bddfca4e78
6 changed files with 25 additions and 15 deletions

View File

@@ -689,7 +689,7 @@ async function installInContext (
if (installCtx.pkgByPkgId[pkg.id].optional) {
// TODO: add parents field to the log
skippedOptionalDependencyLogger.debug({
details: err,
details: err.toString(),
package: {
id: pkg.id,
name: pkg.name,

View File

@@ -219,7 +219,7 @@ async function _rebuild (
if (pkgSnapshot.optional) {
// TODO: add parents field to the log
skippedOptionalDependencyLogger.debug({
details: err,
details: err.toString(),
package: {
id: pkgSnapshot.id || depAbsolutePath,
name: pkgInfo.name,

View File

@@ -21,10 +21,18 @@ export default async function getIsInstallable (
pnpmVersion: string,
},
): Promise<boolean> {
const warn = await installChecks.checkPlatform(pkg) || await installChecks.checkEngine(pkg, {
nodeVersion: options.nodeVersion,
pnpmVersion: options.pnpmVersion,
})
const warn = await installChecks.checkPlatform({
_id: pkgId,
cpu: pkg.cpu,
os: pkg.os,
}) ||
await installChecks.checkEngine({
_id: pkgId,
engines: pkg.engines,
}, {
nodeVersion: options.nodeVersion,
pnpmVersion: options.pnpmVersion,
})
if (!warn) return true
@@ -32,14 +40,14 @@ export default async function getIsInstallable (
if (options.optional) {
skippedOptionalDependencyLogger.debug({
details: warn,
details: warn.toString(),
package: {
id: pkgId,
name: pkg.name,
version: pkg.version,
},
parents: nodeIdToParents(options.nodeId, options.pkgByPkgId),
reason: 'incompatible_engine',
reason: warn.code === 'ENOTSUP' ? 'unsupported_engine' : 'unsupported_platform',
})
return false

View File

@@ -89,7 +89,7 @@ export type StatsMessage = {
})
export type SkippedOptionalDependencyMessage = {
details?: object,
details?: string,
parents?: Array<{id: string, name: string, version: string}>,
} & ({
package: {
@@ -97,7 +97,9 @@ export type SkippedOptionalDependencyMessage = {
name: string,
version: string,
},
reason: 'incompatible_engine' | 'build_failure',
reason: 'unsupported_engine'
| 'unsupported_platform'
| 'build_failure',
} | {
package: {
name: string | undefined,

View File

@@ -274,7 +274,7 @@ async function install (
} catch (err) {
if (wantedDependency.optional) {
skippedOptionalDependencyLogger.debug({
details: err,
details: err.toString(),
package: {
name: wantedDependency.alias,
pref: wantedDependency.pref,

View File

@@ -87,7 +87,7 @@ test('skip optional dependency that does not support the current OS', async (t:
version: '1.0.0',
},
parents: [],
reason: 'incompatible_engine',
reason: 'unsupported_platform',
})
const reportedTimes = reporter.withArgs(logMatcher).callCount
t.equal(reportedTimes, 1, 'skipping optional dependency is logged')
@@ -113,7 +113,7 @@ test('skip optional dependency that does not support the current Node version',
version: '1.0.0',
},
parents: [],
reason: 'incompatible_engine',
reason: 'unsupported_engine',
})
const reportedTimes = reporter.withArgs(logMatcher).callCount
t.equal(reportedTimes, 1, 'skipping optional dependency is logged')
@@ -139,7 +139,7 @@ test('skip optional dependency that does not support the current pnpm version',
version: '1.0.0',
},
parents: [],
reason: 'incompatible_engine',
reason: 'unsupported_engine',
})
const reportedTimes = reporter.withArgs(logMatcher).callCount
t.equal(reportedTimes, 1, 'skipping optional dependency is logged')
@@ -183,7 +183,7 @@ test('optional subdependency is skipped', async (t: tape.Test) => {
version: '1.0.0',
},
],
reason: 'incompatible_engine',
reason: 'unsupported_platform',
})
const reportedTimes = reporter.withArgs(logMatcher).callCount
t.equal(reportedTimes, 1, 'skipping optional dependency is logged')