Add the cli flag --silent to astro which sets astro and snowpack logging to output nothing (#613)

This commit is contained in:
Caleb Jasik 2021-07-07 14:51:54 -05:00 committed by GitHub
parent 047652295b
commit 42a1fd7c16
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
4 changed files with 16 additions and 1 deletions

View file

@ -0,0 +1,5 @@
---
'astro': patch
---
Add command line flag `--silent` to astro to set no output.

View file

@ -78,6 +78,7 @@ function printHelp() {
--no-sitemap Disable sitemap generation (build only).
--reload Clean the cache, reinstalling dependencies.
--verbose Enable verbose logging
--silent Disable logging
--version Show the version number and exit.
--help Show this help message.
`);

View file

@ -159,4 +159,11 @@ function padStr(str: string, len: number) {
return str + spaces;
}
export const defaultLogLevel: LoggerLevel = process.argv.includes('--verbose') ? 'debug' : 'info';
export let defaultLogLevel: LoggerLevel;
if (process.argv.includes('--verbose')) {
defaultLogLevel = 'debug';
} else if (process.argv.includes('--silent')) {
defaultLogLevel = 'silent';
} else {
defaultLogLevel = 'info';
}

View file

@ -4,5 +4,7 @@ import { defaultLogLevel } from './logger.js';
export function configureSnowpackLogger(logger: typeof snowpackLogger) {
if (defaultLogLevel === 'debug') {
logger.level = 'debug';
} else if (defaultLogLevel === 'silent') {
logger.level = 'silent';
}
}