mirror of
https://github.com/withastro/astro.git
synced 2024-12-23 21:53:55 -05:00
Protect against shimmed process usage in Vercel Edge (#5969)
* Protect against shimmed process usage in Vercel Edge * Adding a changeset
This commit is contained in:
parent
4d1e4f6d96
commit
f4c71e5eb9
2 changed files with 19 additions and 4 deletions
7
.changeset/nasty-dolphins-cry.md
Normal file
7
.changeset/nasty-dolphins-cry.md
Normal file
|
@ -0,0 +1,7 @@
|
||||||
|
---
|
||||||
|
'astro': patch
|
||||||
|
---
|
||||||
|
|
||||||
|
Fix usage of logger in Vercel Edge
|
||||||
|
|
||||||
|
This protects against usage of `process` global in shimmed environments.
|
|
@ -101,13 +101,21 @@ function padStr(str: string, len: number) {
|
||||||
|
|
||||||
export let defaultLogLevel: LoggerLevel;
|
export let defaultLogLevel: LoggerLevel;
|
||||||
if (typeof process !== 'undefined') {
|
if (typeof process !== 'undefined') {
|
||||||
if (process.argv.includes('--verbose')) {
|
// This could be a shimmed environment so we don't know that `process` is the full
|
||||||
|
// NodeJS.process. This code treats it as a plain object so TS doesn't let us
|
||||||
|
// get away with incorrect assumptions.
|
||||||
|
let proc: object = process;
|
||||||
|
if('argv' in proc && Array.isArray(proc.argv)) {
|
||||||
|
if (proc.argv.includes('--verbose')) {
|
||||||
defaultLogLevel = 'debug';
|
defaultLogLevel = 'debug';
|
||||||
} else if (process.argv.includes('--silent')) {
|
} else if (proc.argv.includes('--silent')) {
|
||||||
defaultLogLevel = 'silent';
|
defaultLogLevel = 'silent';
|
||||||
} else {
|
} else {
|
||||||
defaultLogLevel = 'info';
|
defaultLogLevel = 'info';
|
||||||
}
|
}
|
||||||
|
} else {
|
||||||
|
defaultLogLevel = 'info';
|
||||||
|
}
|
||||||
} else {
|
} else {
|
||||||
defaultLogLevel = 'info';
|
defaultLogLevel = 'info';
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue