Skip to content

Commit

Permalink
Use native nodejs module for fs and fetch
Browse files Browse the repository at this point in the history
  • Loading branch information
soruly committed Dec 17, 2023
1 parent 870d93f commit c1088d5
Show file tree
Hide file tree
Showing 3 changed files with 83 additions and 117 deletions.
188 changes: 78 additions & 110 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 1 addition & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -28,8 +28,7 @@
"dependencies": {
"dotenv": "^16.3.1",
"express": "^4.18.2",
"express-rate-limit": "^7.1.5",
"node-fetch": "^3.3.2"
"express-rate-limit": "^7.1.5"
},
"devDependencies": {
"prettier": "^3.1.1"
Expand Down
9 changes: 4 additions & 5 deletions server.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
import "dotenv/config";
import fs from "fs";
import fetch from "node-fetch";
import child_process from "child_process";
import fs from "node:fs/promises";
import child_process from "node:child_process";
import express from "express";
import rateLimit from "express-rate-limit";

Expand Down Expand Up @@ -54,8 +53,8 @@ try {
} catch (e) {
REVISION = "";
}
const packageJSON = fs.existsSync("./package.json")
? JSON.parse(fs.readFileSync("./package.json"))
const packageJSON = (await fs.stat("./package.json").catch(() => null))
? JSON.parse(await fs.readFile("./package.json"))
: null;

const getHelpMessage = (botName) =>
Expand Down

0 comments on commit c1088d5

Please sign in to comment.