Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 6 additions & 1 deletion src/utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -566,7 +566,12 @@ export function datetimeString(d: Date): string {
* Indicates whether the end-user is running the CLI from a cloud-based environment.
*/
export function isCloudEnvironment() {
return !!process.env.CODESPACES || !!process.env.GOOGLE_CLOUD_WORKSTATIONS;
return (
!!process.env.CODESPACES ||
!!process.env.GOOGLE_CLOUD_WORKSTATIONS ||
!!process.env.CLOUD_SHELL ||
!!process.env.GOOGLE_CLOUD_SHELL
);
}
Comment on lines 568 to 575
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

medium

For better maintainability and readability, you could define the environment variable names in an array and use the some method directly. This makes it easier to add or remove variables in the future. I've also added an explicit return type for clarity.

Suggested change
export function isCloudEnvironment() {
return !!process.env.CODESPACES || !!process.env.GOOGLE_CLOUD_WORKSTATIONS;
return (
!!process.env.CODESPACES ||
!!process.env.GOOGLE_CLOUD_WORKSTATIONS ||
!!process.env.CLOUD_SHELL ||
!!process.env.GOOGLE_CLOUD_SHELL
);
}
export function isCloudEnvironment(): boolean {
return [
"CODESPACES",
"GOOGLE_CLOUD_WORKSTATIONS",
"CLOUD_SHELL",
"GOOGLE_CLOUD_SHELL",
].some((envVar) => !!process.env[envVar]);
}


/**
Expand Down
Loading