chore: disable verbose output in test environment

This commit is contained in:
Pooya Parsa 2021-02-22 18:47:32 +01:00
parent 8a22fa333e
commit b7b9fbf927
2 changed files with 15 additions and 5 deletions

View File

@ -2,6 +2,7 @@ import hasha from 'hasha'
import { relative } from 'upath'
import { table, getBorderCharacters } from 'table'
import isPrimitive from 'is-primitive'
import stdenv from 'std-env'
import type { ServerMiddleware } from '../../server/middleware'
import virtual from './virtual'
@ -13,13 +14,17 @@ export function middleware (getMiddleware: () => ServerMiddleware[]) {
return virtual({
'~serverMiddleware': () => {
const middleware = getMiddleware()
const dumped = dumpMiddleware(middleware)
if (dumped !== lastDump) {
lastDump = dumped
if (middleware.length) {
console.log('\n\nNitro middleware:\n' + dumped)
if (!stdenv.test) {
const dumped = dumpMiddleware(middleware)
if (dumped !== lastDump) {
lastDump = dumped
if (middleware.length) {
console.log('\n\nNitro middleware:\n' + dumped)
}
}
}
return `
${middleware.filter(m => m.lazy === false).map(m => `import ${getImportId(m.handle)} from '${m.handle}';`).join('\n')}

View File

@ -4,8 +4,13 @@ import prettyBytes from 'pretty-bytes'
import gzipSize from 'gzip-size'
import { readFile } from 'fs-extra'
import chalk from 'chalk'
import stdenv from 'std-env'
export async function printFSTree (dir) {
if (stdenv.test) {
return
}
const files = await globby('**/*.*', { cwd: dir })
const items = (await Promise.all(files.map(async (file) => {