Skip to content

Commit

Permalink
refactor: always use property access for process.env
Browse files Browse the repository at this point in the history
This is in preparation for migrating from webpack to esbuild.

See evanw/esbuild#2050.
  • Loading branch information
fwouts committed Feb 24, 2022
1 parent bfe3d79 commit 4d63251
Show file tree
Hide file tree
Showing 9 changed files with 19 additions and 21 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/test-app-e2e.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -118,7 +118,7 @@ jobs:
issue_number: context.issue.number,
owner: context.repo.owner,
repo: context.repo.repo,
body: `⚠️ Screenshots have changed: group ${process.env["MATRIX_GROUP"]}, ${process.env["MATRIX_OS"]} (Node ${process.env["MATRIX_NODE_VERSION"]})`
body: `⚠️ Screenshots have changed: group ${process.env.MATRIX_GROUP}, ${process.env.MATRIX_OS} (Node ${process.env.MATRIX_NODE_VERSION})`
})
- name: Fail if screenshots have changed on main branch
run: git diff --exit-code
Expand Down
11 changes: 5 additions & 6 deletions app/testing/run-test-suite.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,14 +4,13 @@ import { runTests } from ".";

async function main() {
let failed = false;
const groupCount = parseInt(process.env["GROUP_COUNT"] || "1");
const groupIndex = parseInt(process.env["GROUP_INDEX"] || "0");
const groupCount = parseInt(process.env.GROUP_COUNT || "1");
const groupIndex = parseInt(process.env.GROUP_INDEX || "0");
const setupEnvironmentPath =
process.env["SETUP_ENVIRONMENT_MODULE"] ||
path.resolve(__dirname, "../src");
process.env.SETUP_ENVIRONMENT_MODULE || path.resolve(__dirname, "../src");
const testsPath =
process.env["TESTS_MODULE"] || path.resolve(__dirname, "../tests");
const headless = process.env["HEADLESS"] !== "0";
process.env.TESTS_MODULE || path.resolve(__dirname, "../tests");
const headless = process.env.HEADLESS !== "0";
const browser = await playwright.chromium.launch({
headless,
devtools: !headless,
Expand Down
4 changes: 2 additions & 2 deletions cli/src/main.ts
Original file line number Diff line number Diff line change
Expand Up @@ -31,8 +31,8 @@ program
.option(...VERBOSE_OPTION)
.action(async (dirPath: string | undefined, options: SharedOptions) => {
const previewjs = await load({
installDir: process.env["PREVIEWJS_MODULES_DIR"] || "..",
packageName: process.env["PREVIEWJS_PACKAGE_NAME"] || "@previewjs/app",
installDir: process.env.PREVIEWJS_MODULES_DIR || "..",
packageName: process.env.PREVIEWJS_PACKAGE_NAME || "@previewjs/app",
});
const workspace = await previewjs.getWorkspace({
versionCode: `cli-${version}`,
Expand Down
4 changes: 2 additions & 2 deletions integrations/intellij/controller/src/install.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,11 +7,11 @@ main().catch((e) => {
});

async function main() {
const packageName = process.env["PREVIEWJS_PACKAGE_NAME"];
const packageName = process.env.PREVIEWJS_PACKAGE_NAME;
if (!packageName) {
throw new Error(`Missing environment variable: PREVIEWJS_PACKAGE_NAME`);
}
const packageVersion = process.env["PREVIEWJS_PACKAGE_VERSION"];
const packageVersion = process.env.PREVIEWJS_PACKAGE_VERSION;
if (!packageVersion) {
throw new Error(`Missing environment variable: PREVIEWJS_PACKAGE_VERSION`);
}
Expand Down
4 changes: 2 additions & 2 deletions integrations/intellij/controller/src/is-installed.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,11 +7,11 @@ main().catch((e) => {
});

async function main() {
const packageName = process.env["PREVIEWJS_PACKAGE_NAME"];
const packageName = process.env.PREVIEWJS_PACKAGE_NAME;
if (!packageName) {
throw new Error(`Missing environment variable: PREVIEWJS_PACKAGE_NAME`);
}
const packageVersion = process.env["PREVIEWJS_PACKAGE_VERSION"];
const packageVersion = process.env.PREVIEWJS_PACKAGE_VERSION;
if (!packageVersion) {
throw new Error(`Missing environment variable: PREVIEWJS_PACKAGE_VERSION`);
}
Expand Down
6 changes: 3 additions & 3 deletions integrations/intellij/controller/src/run-server.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,8 @@ import {
UpdatePendingFileResponse,
} from "./api";

const port = parseInt(process.env["PORT"] || "9100");
const version = process.env["PREVIEWJS_INTELLIJ_VERSION"];
const port = parseInt(process.env.PORT || "9100");
const version = process.env.PREVIEWJS_INTELLIJ_VERSION;

if (!version) {
throw new Error(`IntelliJ version was not set`);
Expand All @@ -31,7 +31,7 @@ main().catch((e) => {
});

async function main() {
const packageName = process.env["PREVIEWJS_PACKAGE_NAME"];
const packageName = process.env.PREVIEWJS_PACKAGE_NAME;
if (!packageName) {
throw new Error(`Missing environment variable: PREVIEWJS_PACKAGE_NAME`);
}
Expand Down
2 changes: 1 addition & 1 deletion integrations/intellij/controller/webpack.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ module.exports = {
install: "./src/install.ts",
"run-server": "./src/run-server.ts",
},
mode: process.env["NODE_ENV"] || "production",
mode: process.env.NODE_ENV || "production",
target: "node",
module: {
rules: [
Expand Down
6 changes: 3 additions & 3 deletions integrations/vscode/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -28,15 +28,15 @@ let dispose = async () => {
export async function activate(context: vscode.ExtensionContext) {
const config = vscode.workspace.getConfiguration();

const packageName = process.env["PREVIEWJS_PACKAGE_NAME"];
const packageName = process.env.PREVIEWJS_PACKAGE_NAME;
if (!packageName) {
throw new Error(`Missing environment variable: PREVIEWJS_PACKAGE_NAME`);
}

let requirePath = process.env["PREVIEWJS_MODULES_DIR"];
let requirePath = process.env.PREVIEWJS_MODULES_DIR;
if (!requirePath) {
requirePath = path.join(__dirname, "installed");
const packageVersion = process.env["PREVIEWJS_PACKAGE_VERSION"];
const packageVersion = process.env.PREVIEWJS_PACKAGE_VERSION;
if (!packageVersion) {
throw new Error(
`Missing environment variable: PREVIEWJS_PACKAGE_VERSION`
Expand Down
1 change: 0 additions & 1 deletion tsconfig.base.json
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,6 @@
"noImplicitReturns": true,
"noFallthroughCasesInSwitch": true,
"noUncheckedIndexedAccess": true,
"noPropertyAccessFromIndexSignature": true,
"esModuleInterop": true,
"skipLibCheck": true,
"forceConsistentCasingInFileNames": true
Expand Down

0 comments on commit 4d63251

Please sign in to comment.