Replaced deprecated Buffer constructor with Buffer.from

This commit is contained in:
Kir_Antipov 2021-12-11 14:03:24 +03:00
parent bbe6c59888
commit 8c7eeb8fd9
3 changed files with 14 additions and 1 deletions

View file

@ -4,7 +4,7 @@
"description": "GitHub Action that helps you publish your Minecraft mods", "description": "GitHub Action that helps you publish your Minecraft mods",
"main": "src/index.ts", "main": "src/index.ts",
"scripts": { "scripts": {
"build": "ncc build --source-map --license license.txt", "build": "ncc build --source-map --license license.txt && ncc run scripts/index.ts",
"test:lint": "eslint src/**/*.ts && eslint test/**/*.ts", "test:lint": "eslint src/**/*.ts && eslint test/**/*.ts",
"test:unit": "jest", "test:unit": "jest",
"test": "npm run test:lint && npm run test:unit" "test": "npm run test:lint && npm run test:unit"

10
scripts/buffer-fix.ts Normal file
View file

@ -0,0 +1,10 @@
import fs from "fs";
export default function fixDeprecatedBuffer() {
const files = fs.readdirSync("./dist", { withFileTypes: true });
for (const file of files.filter(x => x.isFile())) {
const content = fs.readFileSync(`./dist/${file.name}`, "utf8");
const fixedContent = content.replace(/new Buffer\(/g, "Buffer.from(");
fs.writeFileSync(`./dist/${file.name}`, fixedContent, "utf8");
}
}

3
scripts/index.ts Normal file
View file

@ -0,0 +1,3 @@
import fixDeprecatedBuffer from "./buffer-fix";
fixDeprecatedBuffer();