Use node prefix for build-in modules (#3340)

It is basically a cosmetic thing, but has the following advantages:

1. Consistency with the official node documentation. The prefix is used
there.
2. It is easier to recognize the build-in modules.
This commit is contained in:
Kristjan ESPERANTO
2024-01-08 17:45:54 +01:00
committed by GitHub
parent 407072d12d
commit 4bbd35fa6a
28 changed files with 489 additions and 132 deletions

View File

@@ -3,7 +3,7 @@ const helpers = require("./helpers/global-setup");
describe("All font files from roboto.css should be downloadable", () => {
const fontFiles = [];
// Statements below filters out all 'url' lines in the CSS file
const fileContent = require("fs").readFileSync(`${__dirname}/../../fonts/roboto.css`, "utf8");
const fileContent = require("node:fs").readFileSync(`${__dirname}/../../fonts/roboto.css`, "utf8");
const regex = /\burl\(['"]([^'"]+)['"]\)/g;
let match = regex.exec(fileContent);
while (match !== null) {

View File

@@ -1,4 +1,4 @@
const path = require("path");
const path = require("node:path");
const auth = require("express-basic-auth");
const express = require("express");

View File

@@ -6,7 +6,7 @@ describe("App environment", () => {
let serverProcess;
beforeAll(async () => {
process.env.MM_CONFIG_FILE = "tests/configs/default.js";
serverProcess = await require("child_process").spawn("npm", ["run", "server"], { env: process.env, detached: true });
serverProcess = await require("node:child_process").spawn("npm", ["run", "server"], { env: process.env, detached: true });
// we have to wait until the server is startet
await delay(2000);
});

View File

@@ -1,4 +1,4 @@
const fs = require("fs");
const fs = require("node:fs");
const helpers = require("./helpers/global-setup");
describe("templated config with port variable", () => {

View File

@@ -1,5 +1,5 @@
const fs = require("fs");
const path = require("path");
const fs = require("node:fs");
const path = require("node:path");
const helmet = require("helmet");
const { JSDOM } = require("jsdom");
const express = require("express");

View File

@@ -1,4 +1,4 @@
const events = require("events");
const events = require("node:events");
const helpers = require("./helpers/global-setup");
describe("Electron app environment", () => {

View File

@@ -1,4 +1,4 @@
const path = require("path");
const path = require("node:path");
const { JSDOM } = require("jsdom");
describe("File js/class", () => {

View File

@@ -1,4 +1,4 @@
const path = require("path");
const path = require("node:path");
const helmet = require("helmet");
const { JSDOM } = require("jsdom");
const express = require("express");

View File

@@ -1,4 +1,4 @@
const path = require("path");
const path = require("node:path");
const { JSDOM } = require("jsdom");
describe("Test function cmpVersions in js/module.js", () => {

View File

@@ -1,9 +1,9 @@
jest.mock("util", () => ({
jest.mock("node:util", () => ({
...jest.requireActual("util"),
promisify: jest.fn()
}));
jest.mock("fs", () => ({
jest.mock("node:fs", () => ({
...jest.requireActual("fs"),
statSync: jest.fn()
}));
@@ -29,7 +29,7 @@ describe("Updatenotification", () => {
let gitTagListOut;
beforeAll(async () => {
const { promisify } = require("util");
const { promisify } = require("node:util");
promisify.mockReturnValue(execMock);
const GitHelper = require("../../../modules/default/updatenotification/git_helper");

View File

@@ -1,5 +1,5 @@
const fs = require("fs");
const path = require("path");
const fs = require("node:fs");
const path = require("node:path");
const root_path = path.join(__dirname, "../../..");

View File

@@ -1,5 +1,5 @@
const fs = require("fs");
const path = require("path");
const fs = require("node:fs");
const path = require("node:path");
const root_path = path.join(__dirname, "../../..");
const version = require(`${__dirname}/../../../package.json`).version;

View File

@@ -1,7 +1,7 @@
const fs = require("fs");
const path = require("path");
const util = require("util");
const exec = util.promisify(require("child_process").exec);
const fs = require("node:fs");
const path = require("node:path");
const util = require("node:util");
const exec = util.promisify(require("node:child_process").exec);
const _ = require("lodash");
/**