-
Notifications
You must be signed in to change notification settings - Fork 432
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
chore(e2e): update docs and make missing env more clear (#5421)
* chore(e2e): update docs and make missing env more clear * chore(e2e): fix README.md
- Loading branch information
Showing
5 changed files
with
61 additions
and
43 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
type KnownEnvVar = | ||
| 'SANITY_E2E_SESSION_TOKEN' | ||
| 'SANITY_E2E_PROJECT_ID' | ||
| 'SANITY_E2E_DATASET' | ||
| 'CI' | ||
|
||
/** | ||
* Read an environment variable, parsing the response as a boolean, using loose | ||
* constraints (`true`, `1`, `yes` are all considered true, everything else is false) | ||
* | ||
* @param flag - The environment variable to read, eg `SOME_FLAG` | ||
* @param defaultValue - The default value to use if it is not set | ||
* @returns A boolean value | ||
* @internal | ||
*/ | ||
export function readBoolEnv(flag: KnownEnvVar, defaultValue: boolean): boolean { | ||
const value = findEnv(flag) | ||
if (value === undefined) { | ||
return defaultValue | ||
} | ||
|
||
return value === 'true' || value === '1' || value === 'yes' | ||
} | ||
|
||
export function readEnv(name: KnownEnvVar): string { | ||
const val = findEnv(name) | ||
if (val === undefined) { | ||
throw new Error( | ||
`Missing required environment variable "${name}". Make sure to copy \`.env.example\` to \`.env.local\``, | ||
) | ||
} | ||
return val | ||
} | ||
|
||
export function findEnv(name: KnownEnvVar): string | undefined { | ||
return process.env[name] | ||
} |
a63a20a
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Successfully deployed to the following URLs:
performance-studio – ./
performance-studio.sanity.build
performance-studio-git-next.sanity.build
a63a20a
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Successfully deployed to the following URLs:
test-studio – ./
test-studio-git-next.sanity.build
test-studio.sanity.build