From 4936d8f8e09704aac20ae553cdd2496fa9041655 Mon Sep 17 00:00:00 2001 From: Assaf Arkin Date: Sun, 25 Nov 2018 12:18:01 -0800 Subject: [PATCH] new Buffer deprecated --- lib/pass.js | 6 +++--- lib/zip.js | 14 +++++++------- package.json | 12 +++++++----- test/pass_test.js | 2 +- 4 files changed, 18 insertions(+), 16 deletions(-) diff --git a/lib/pass.js b/lib/pass.js index e8cec75..fd298b3 100644 --- a/lib/pass.js +++ b/lib/pass.js @@ -236,7 +236,7 @@ Pass.prototype.pipe = function(output) { } // Create pass.json - var passJson = new Buffer(JSON.stringify(this.getPassJSON()), "utf-8"); + var passJson = Buffer.from(JSON.stringify(this.getPassJSON()), "utf-8"); addFile("pass.json").end(passJson, "utf8"); var expecting = 0; @@ -362,13 +362,13 @@ function signManifest(template, manifest, callback) { "-passin", "pass:" + template.password ]; var sign = execFile("openssl", args, { stdio: "pipe" }, function(error, stdout, stderr) { - var trimmedStderr = stderr.trim(); + var trimmedStderr = stderr.trim(); // Windows outputs some unhelpful error messages, but still produces a valid signature if (error || (trimmedStderr && trimmedStderr.indexOf('- done') < 0)) { callback(new Error(stderr)); } else { var signature = stdout.split(/(\r\n|\n\n)/)[3]; - callback(null, new Buffer(signature, "base64")); + callback(null, Buffer.from(signature, "base64")); } }); sign.stdin.write(manifest); diff --git a/lib/zip.js b/lib/zip.js index 5632f7d..026aace 100644 --- a/lib/zip.js +++ b/lib/zip.js @@ -118,8 +118,8 @@ Zip.prototype._flush = function() { // Write next central directory header. Returns header size; Zip.prototype._writeCentralDirectoryHeader = function(file) { - var filename = new Buffer(file.filename, "utf-8"); - var buffer = new Buffer(46 + filename.length); + var filename = Buffer.from(file.filename, "utf-8"); + var buffer = Buffer.alloc(46 + filename.length); // central file header signature buffer.writeInt32LE(0x02014b50, 0); @@ -165,7 +165,7 @@ Zip.prototype._writeCentralDirectoryHeader = function(file) { // Write end of central directory record and close output stream. Zip.prototype._writeEndOfCentralDirectory = function(offsetOfCentralDirectory, sizeOfCentralDirectory) { - var buffer = new Buffer(22); + var buffer = Buffer.alloc(22); // end of central dir signature buffer.writeInt32LE(0x06054b50, 0); // number of this disk @@ -277,7 +277,7 @@ File.prototype.write = function(buffer, encoding) { if (!this.writable) throw new Error("This file no longer open for writing"); if (typeof(buffer) == "string" || buffer instanceof String) - buffer = new Buffer(buffer, encoding || "utf8"); + buffer = Buffer.from(buffer, encoding || "utf8"); // crc-32 for (var i = 0; i < buffer.length; i++) { @@ -315,8 +315,8 @@ File.prototype.destroy = function() { File.prototype._writeLocalFileHeader = function() { debug("Started writing", this.filename); this._offset = this.zip._offset; - var filename = new Buffer(this.filename, "utf-8"); - var buffer = new Buffer(30 + filename.length); + var filename = Buffer.from(this.filename, "utf-8"); + var buffer = Buffer.alloc(30 + filename.length); // local file header signature buffer.writeInt32LE(0x04034b50, 0); @@ -391,7 +391,7 @@ File.prototype._doneWritingFile = function() { File.prototype._writeDataDescriptor = function() { // Write data descriptor at end of file: this is used for data we can only // determine after processing file (CRC, length). - var buffer = new Buffer(16); + var buffer = Buffer.alloc(16); buffer.writeInt32LE(0x08074b50, 0); buffer.writeInt32LE(this._crc ^ -1, 4); // compressed size diff --git a/package.json b/package.json index 71af01a..988a472 100644 --- a/package.json +++ b/package.json @@ -1,4 +1,5 @@ -{ "name": "passbook", +{ + "name": "passbook", "description": "iOS Passbook for the Node hacker", "homepage": "https://github.com/assaf/node-passbook", "version": "2.1.2", @@ -11,12 +12,12 @@ "node-passbook": "./bin/node-passbook" }, "dependencies": { - "async": "^0.9.0", - "cli": "0.6.5", + "async": "^2.6.1", + "cli": "^1.0.1", "follow-redirects": "^1.2.3" }, "devDependencies": { - "mocha": "2.1.0" + "mocha": "^5.2.0" }, "scripts": { "test": "mocha" @@ -35,7 +36,8 @@ "url": "http://github.com/assaf/node-passbook/issues" }, "licenses": [ - { "type": "MIT", + { + "type": "MIT", "url": "http://github.com/assaf/node-passbook/blob/master/MIT-LICENSE" } ] diff --git a/test/pass_test.js b/test/pass_test.js index 2559ee6..7e59845 100644 --- a/test/pass_test.js +++ b/test/pass_test.js @@ -247,7 +247,7 @@ function unzip(zipFile, filename, callback) { if (error) { callback(new Error(stdout)); } else { - callback(null, new Buffer(stdout, "binary")); + callback(null, Buffer.from(stdout, "binary")); } }); }