mirror of
https://github.com/react/react-native-devtools-frontend.git
synced 2026-10-07 04:26:32 +08:00
Bug: none Change-Id: I314035b082d7037a2be5755b634c0c8b37876614 Reviewed-on: https://chromium-review.googlesource.com/c/devtools/devtools-frontend/+/3607836 Commit-Queue: Danil Somsikov <dsv@chromium.org> Auto-Submit: Danil Somsikov <dsv@chromium.org> Reviewed-by: Philip Pfaffe <pfaffe@chromium.org> Commit-Queue: Philip Pfaffe <pfaffe@chromium.org>
42 lines
1.8 KiB
TypeScript
42 lines
1.8 KiB
TypeScript
// Copyright 2020 The Chromium Authors. All rights reserved.
|
|
// Use of this source code is governed by a BSD-style license that can be
|
|
// found in the LICENSE file.
|
|
|
|
interface SupportedEnvVars {
|
|
/* eslint-disable @typescript-eslint/naming-convention */
|
|
NO_SHUFFLE: boolean; // Whether or not to shuffle tests.
|
|
STRESS: boolean; // Stress test (slowdown CPU; multiple iterations)
|
|
VERBOSE: boolean; // Log stdout from the workers.
|
|
THROTTLE: number; // CPU throttle multiplier.
|
|
TEST_LIST: string; // Absolute path to the test list.
|
|
TEST_PATTERNS: string; // A comma-separated list of extglob pattern to filter the tests.
|
|
DEBUG_TEST: boolean; // Debug mode. When enabled, has longer timeouts and runs Chrome in head mode.
|
|
ITERATIONS: number; // Number of test iterations.
|
|
JOBS: number; // Number of workers to use.
|
|
SLOWMO: number; // Number of milliseconds between actions. Recommended value: 50.
|
|
CHROME_BIN: string; // Absolute path to the Chrome binary.
|
|
INTERACTIVE: boolean; // [Unused]: Placeholder for screenshot diffing.
|
|
TIMEOUT: number; // The timeout in ms to wait for tests.
|
|
CHROME_FEATURES: string; // --enable-features={} for the Chrome binary.
|
|
/* eslint-enable @typescript-eslint/naming-convention */
|
|
}
|
|
|
|
export function getEnvVar<Key extends keyof SupportedEnvVars>(
|
|
name: Key, defaultValue?: SupportedEnvVars[Key]): SupportedEnvVars[Key] {
|
|
const envVar = process.env[name];
|
|
|
|
if (typeof defaultValue === 'boolean') {
|
|
return (Boolean(envVar)) as SupportedEnvVars[Key];
|
|
}
|
|
|
|
if (typeof defaultValue === 'number') {
|
|
let value = Number(envVar);
|
|
if (Number.isNaN(value)) {
|
|
value = defaultValue;
|
|
}
|
|
return value as SupportedEnvVars[Key];
|
|
}
|
|
|
|
return (envVar || defaultValue) as SupportedEnvVars[Key];
|
|
}
|