From ff0e8dacf40322914bf463b1c8fdae8b5d117173 Mon Sep 17 00:00:00 2001 From: Zoltan Kochan Date: Tue, 19 Dec 2017 22:13:34 +0200 Subject: [PATCH] feat: show less output during recursive installation --- src/index.ts | 86 +++++++++++++++++++++++++++------------------------- 1 file changed, 44 insertions(+), 42 deletions(-) diff --git a/src/index.ts b/src/index.ts index acacc1b74e..98fd996275 100644 --- a/src/index.ts +++ b/src/index.ts @@ -142,10 +142,10 @@ export function toOutput$ ( outputs.push(tarballsProgressOutput$) - const deprecationLog$ = log$ - .filter((log) => log.name === 'pnpm:deprecation') as Stream - if (!isRecursive) { + const deprecationLog$ = log$ + .filter((log) => log.name === 'pnpm:deprecation') as Stream + const pkgsDiff$ = getPkgsDiff(log$, deprecationLog$) const summaryLog$ = log$ @@ -174,20 +174,20 @@ export function toOutput$ ( .map(xs.of) outputs.push(summaryOutput$) + + const deprecationOutput$ = deprecationLog$ + // print warnings only about deprecated packages from the root + .filter((log) => log.depth === 0) + .map((log) => { + return { + msg: formatWarn(`${chalk.red('deprecated')} ${log.pkgName}@${log.pkgVersion}: ${log.deprecated}`), + } + }) + .map(xs.of) + + outputs.push(deprecationOutput$) } - const deprecationOutput$ = deprecationLog$ - // print warnings only about deprecated packages from the root - .filter((log) => log.depth === 0) - .map((log) => { - return { - msg: formatWarn(`${chalk.red('deprecated')} ${log.pkgName}@${log.pkgVersion}: ${log.deprecated}`), - } - }) - .map(xs.of) - - outputs.push(deprecationOutput$) - const lifecycleMessages: {[pkgId: string]: string} = {} const lifecycleOutput$ = xs.of( log$ @@ -202,38 +202,40 @@ export function toOutput$ ( outputs.push(lifecycleOutput$) - const installCheckOutput$ = log$ - .filter((log) => log.name === 'pnpm:install-check') - .map(formatInstallCheck) - .filter(Boolean) - .map((msg) => ({msg})) - .map(xs.of) as Stream> + if (!isRecursive) { + const installCheckOutput$ = log$ + .filter((log) => log.name === 'pnpm:install-check') + .map(formatInstallCheck) + .filter(Boolean) + .map((msg) => ({msg})) + .map(xs.of) as Stream> - outputs.push(installCheckOutput$) + outputs.push(installCheckOutput$) - const registryOutput$ = log$ - .filter((log) => log.name === 'pnpm:registry' && log.level === 'warn') - .map((log: RegistryLog) => ({msg: formatWarn(log.message)})) - .map(xs.of) + const registryOutput$ = log$ + .filter((log) => log.name === 'pnpm:registry' && log.level === 'warn') + .map((log: RegistryLog) => ({msg: formatWarn(log.message)})) + .map(xs.of) - outputs.push(registryOutput$) + outputs.push(registryOutput$) - const miscOutput$ = log$ - .filter((log) => log.name as string === 'pnpm' || !isRecursive && log.name as string === 'pnpm:link') - .map((obj) => { - if (obj.level === 'debug') return - if (obj.level === 'warn') { - return formatWarn(obj['message']) - } - if (obj.level === 'error') { - return reportError(obj) - } - return obj['message'] - }) - .map((msg) => ({msg})) - .map(xs.of) + const miscOutput$ = log$ + .filter((log) => log.name as string === 'pnpm' || !isRecursive && log.name as string === 'pnpm:link') + .map((obj) => { + if (obj.level === 'debug') return + if (obj.level === 'warn') { + return formatWarn(obj['message']) + } + if (obj.level === 'error') { + return reportError(obj) + } + return obj['message'] + }) + .map((msg) => ({msg})) + .map(xs.of) - outputs.push(miscOutput$) + outputs.push(miscOutput$) + } return mergeOutputs(outputs) }