Skip to content

Commit

Permalink
[INTERNAL] Replace deprecated new Buffer() calls
Browse files Browse the repository at this point in the history
Replacing deprecated 'new Buffer(string)' with 'Buffer.from(string)'.

Resolves a TypeError being thrown in our tests when executed with
Node 20.15.0 or 22.3.0.

Root cause: nodejs/node#53075
  • Loading branch information
RandomByte committed Jul 2, 2024
1 parent f119ccd commit 328a63c
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 4 deletions.
6 changes: 3 additions & 3 deletions test/lib/processors/minifier.js
Original file line number Diff line number Diff line change
Expand Up @@ -1512,7 +1512,7 @@ test("getSourceMapFromUrl: Unexpected data: format", async (t) => {

test("getSourceMapFromUrl: File reference", async (t) => {
const {getSourceMapFromUrl} = __localFunctions__;
const readFileStub = sinon.stub().resolves(new Buffer("Source Map Content"));
const readFileStub = sinon.stub().resolves(Buffer.from("Source Map Content"));
const sourceMappingUrl = `./other/file.map`;

const res = await getSourceMapFromUrl({
Expand Down Expand Up @@ -1544,7 +1544,7 @@ test("getSourceMapFromUrl: File reference not found", async (t) => {

test("getSourceMapFromUrl: HTTPS URL reference", async (t) => {
const {getSourceMapFromUrl} = __localFunctions__;
const readFileStub = sinon.stub().resolves(new Buffer("Source Map Content"));
const readFileStub = sinon.stub().resolves(Buffer.from("Source Map Content"));
const sourceMappingUrl = `https://ui5.sap.com/resources/my/test/module.js.map`;

const res = await getSourceMapFromUrl({
Expand All @@ -1559,7 +1559,7 @@ test("getSourceMapFromUrl: HTTPS URL reference", async (t) => {

test("getSourceMapFromUrl: Absolute path reference", async (t) => {
const {getSourceMapFromUrl} = __localFunctions__;
const readFileStub = sinon.stub().resolves(new Buffer("Source Map Content"));
const readFileStub = sinon.stub().resolves(Buffer.from("Source Map Content"));
const sourceMappingUrl = `/some/file.map`;

const res = await getSourceMapFromUrl({
Expand Down
2 changes: 1 addition & 1 deletion test/lib/tasks/buildThemes.js
Original file line number Diff line number Diff line change
Expand Up @@ -493,7 +493,7 @@ test.serial("buildThemes (useWorkers = true)", async (t) => {
};
const lessResource = {
getPath: () => "/resources/test/library.source.less",
getBuffer: () => new Buffer("/** test comment */")
getBuffer: () => Buffer.from("/** test comment */")
};

const workspace = {
Expand Down

0 comments on commit 328a63c

Please sign in to comment.