Skip to content

Commit

Permalink
refactor: avoid require for dotenv.config() (#1894)
Browse files Browse the repository at this point in the history
  • Loading branch information
Uzlopak committed Nov 12, 2023
1 parent 3694baf commit c2b7cb9
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 4 deletions.
4 changes: 2 additions & 2 deletions src/bin/probot-receive.ts
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
// Usage: probot receive -e push -p path/to/payload app.js

import express, { Router } from "express";

require("dotenv").config();
import { config as dotenvConfig } from "dotenv";
dotenvConfig();

import path from "path";
import { randomUUID as uuidv4 } from "crypto";
Expand Down
3 changes: 2 additions & 1 deletion src/bin/probot.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
import program from "commander";
import { isSupportedNodeVersion } from "../helpers/is-supported-node-version";
import { config as dotenvConfig } from "dotenv";

require("dotenv").config();
dotenvConfig();

const pkg = require("../../package");

Expand Down
3 changes: 2 additions & 1 deletion src/run.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ import { Server } from "./server/server";
import { defaultApp } from "./apps/default";
import { resolveAppFunction } from "./helpers/resolve-app-function";
import { isProduction } from "./helpers/is-production";
import { config as dotenvConfig } from "dotenv";

type AdditionalOptions = {
env: Record<string, string | undefined>;
Expand All @@ -23,7 +24,7 @@ export async function run(
appFnOrArgv: ApplicationFunction | string[],
additionalOptions?: AdditionalOptions,
) {
require("dotenv").config();
dotenvConfig();

const envOptions = readEnvOptions(additionalOptions?.env);
const cliOptions = Array.isArray(appFnOrArgv)
Expand Down

0 comments on commit c2b7cb9

Please sign in to comment.