Skip to content

Commit

Permalink
Eliminate log warning about use of deprecated new Buffer() (#1134)
Browse files Browse the repository at this point in the history
* Bump version after release

* Stop using deprecated `new Buffer()` (fixes #1133)
  • Loading branch information
gjsjohnmurray authored Jun 22, 2023
1 parent 2fe5ea5 commit ac14056
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 10 deletions.
2 changes: 1 addition & 1 deletion packages/extension/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
"name": "sqltools",
"displayName": "SQLTools",
"description": "Connecting users to many of the most commonly used databases. Welcome to database management done right.",
"version": "0.27.1",
"version": "0.27.2-SNAPSHOT",
"publisher": "mtxr",
"license": "MIT",
"preview": false,
Expand Down
2 changes: 1 addition & 1 deletion packages/extension/test/__mocks__/fs.ts
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ function existsSync(directoryPath) {
}

function writeFileSync(directoryPath, content) {
mockFiles[directoryPath] = new Buffer(content);
mockFiles[directoryPath] = Buffer.from(content);
}

fs.readFileSync = readFileSync;
Expand Down
11 changes: 3 additions & 8 deletions packages/util/persistence/serializable-storage.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ export default class SerializableStorage<Item, Key = string | number | Symbol> {

public read(): this {
try {
const content = fs.readFileSync(this.storagePath, { encoding: this.encoding });
const content = fs.readFileSync(this.storagePath, this.encoding);
if (content && content.length > 0) {
this.items = JSON.parse(content);
} else {
Expand All @@ -27,16 +27,11 @@ export default class SerializableStorage<Item, Key = string | number | Symbol> {
return this;
}

private serializeContent(): Buffer {
return new Buffer(JSON.stringify(this.items, null, 2), 'utf8');
}
public save(): this {
return this.write();
}
private write(): this {
fs.writeFileSync(this.storagePath, this.serializeContent());
fs.writeFileSync(this.storagePath, JSON.stringify(this.items, null, 2), this.encoding);
return this;
}

public reset(): this {
this.items = JSON.parse(this.defaultSerializable);
return this;
Expand Down

0 comments on commit ac14056

Please sign in to comment.