diff --git a/.travis.yml b/.travis.yml index 77f07b1..e303031 100644 --- a/.travis.yml +++ b/.travis.yml @@ -1,6 +1,5 @@ language: node_js node_js: - - "0.10" - - '0.12' - - '4' - - '5' + - '6' + - '8' + - '10' diff --git a/extract.js b/extract.js index 19a4255..1a2a445 100644 --- a/extract.js +++ b/extract.js @@ -1,6 +1,5 @@ var util = require('util') var bl = require('bl') -var xtend = require('xtend') var headers = require('./headers') var Writable = require('readable-stream').Writable @@ -98,7 +97,7 @@ var Extract = function (opts) { var onpaxheader = function () { var size = self._header.size self._pax = headers.decodePax(b.slice(0, size)) - if (self._paxGlobal) self._pax = xtend(self._paxGlobal, self._pax) + if (self._paxGlobal) self._pax = Object.assign({}, self._paxGlobal, self._pax) b.consume(size) onstreamend() } diff --git a/headers.js b/headers.js index 6efbc4a..8571c87 100644 --- a/headers.js +++ b/headers.js @@ -1,5 +1,4 @@ -var toBuffer = require('to-buffer') -var alloc = require('buffer-alloc') +var alloc = Buffer.alloc var ZEROS = '0000000000000000000' var SEVENS = '7777777777777777777' @@ -172,7 +171,7 @@ exports.encodePax = function (opts) { // TODO: encode more stuff in pax result += addLength(' ' + key + '=' + pax[key] + '\n') } } - return toBuffer(result) + return Buffer.from(result) } exports.decodePax = function (buf) { diff --git a/pack.js b/pack.js index 72d96a0..ba4eece 100644 --- a/pack.js +++ b/pack.js @@ -1,8 +1,7 @@ var constants = require('fs-constants') var eos = require('end-of-stream') -var util = require('util') -var alloc = require('buffer-alloc') -var toBuffer = require('to-buffer') +var inherits = require('inherits') +var alloc = Buffer.alloc var Readable = require('readable-stream').Readable var Writable = require('readable-stream').Writable @@ -41,7 +40,7 @@ var Sink = function (to) { this._destroyed = false } -util.inherits(Sink, Writable) +inherits(Sink, Writable) Sink.prototype._write = function (data, enc, cb) { this.written += data.length @@ -62,7 +61,7 @@ var LinkSink = function () { this._destroyed = false } -util.inherits(LinkSink, Writable) +inherits(LinkSink, Writable) LinkSink.prototype._write = function (data, enc, cb) { this.linkname += this._decoder.write(data) @@ -80,7 +79,7 @@ var Void = function () { this._destroyed = false } -util.inherits(Void, Writable) +inherits(Void, Writable) Void.prototype._write = function (data, enc, cb) { cb(new Error('No body allowed for this entry')) @@ -103,7 +102,7 @@ var Pack = function (opts) { this._stream = null } -util.inherits(Pack, Readable) +inherits(Pack, Readable) Pack.prototype.entry = function (header, buffer, callback) { if (this._stream) throw new Error('already piping an entry') @@ -125,7 +124,7 @@ Pack.prototype.entry = function (header, buffer, callback) { if (!header.gid) header.gid = 0 if (!header.mtime) header.mtime = new Date() - if (typeof buffer === 'string') buffer = toBuffer(buffer) + if (typeof buffer === 'string') buffer = Buffer.from(buffer) if (Buffer.isBuffer(buffer)) { header.size = buffer.length this._encode(header) diff --git a/package.json b/package.json index e15eb27..adbc4e5 100644 --- a/package.json +++ b/package.json @@ -3,22 +3,17 @@ "version": "1.6.2", "description": "tar-stream is a streaming tar parser and generator and nothing else. It is streams2 and operates purely using streams which means you can easily extract/parse tarballs without ever hitting the file system.", "author": "Mathias Buus ", - "engines": { - "node": ">= 0.8.0" - }, "dependencies": { - "bl": "^1.0.0", - "buffer-alloc": "^1.2.0", - "end-of-stream": "^1.0.0", + "bl": "^2.2.0", + "end-of-stream": "^1.4.1", "fs-constants": "^1.0.0", - "readable-stream": "^2.3.0", - "to-buffer": "^1.1.1", - "xtend": "^4.0.0" + "inherits": "^2.0.3", + "readable-stream": "^3.1.1" }, "devDependencies": { - "concat-stream": "^1.6.2", - "standard": "^11.0.1", - "tape": "^4.9.0" + "concat-stream": "^2.0.0", + "standard": "^12.0.1", + "tape": "^4.9.2" }, "scripts": { "test": "standard && tape test/extract.js test/pack.js", diff --git a/test/extract.js b/test/extract.js index a244c0b..68aeb8b 100644 --- a/test/extract.js +++ b/test/extract.js @@ -363,7 +363,7 @@ test('unicode-bsd', function (t) { // can unpack a bsdtar unicoded tarball gid: 20, size: 4, mtime: new Date(1387588646000), - pax: {'SCHILY.dev': '16777217', 'SCHILY.ino': '3599143', 'SCHILY.nlink': '1', atime: '1387589077', ctime: '1387588646', path: 'høllø.txt'}, + pax: { 'SCHILY.dev': '16777217', 'SCHILY.ino': '3599143', 'SCHILY.nlink': '1', atime: '1387589077', ctime: '1387588646', path: 'høllø.txt' }, type: 'file', linkname: null, uname: 'maf', @@ -400,7 +400,7 @@ test('unicode', function (t) { // can unpack a bsdtar unicoded tarball gid: 20, size: 8, mtime: new Date(1387580181000), - pax: {path: 'høstål.txt'}, + pax: { path: 'høstål.txt' }, type: 'file', linkname: null, uname: 'maf', diff --git a/test/pack.js b/test/pack.js index fef5dc1..e19baba 100644 --- a/test/pack.js +++ b/test/pack.js @@ -74,7 +74,7 @@ test('pax', function (t) { gname: 'staff', uid: 501, gid: 20, - pax: {special: 'sauce'} + pax: { special: 'sauce' } }, 'hello world\n') pack.finalize()