From dc473994ee9d17359e285a3bfbf6b9b6564b0390 Mon Sep 17 00:00:00 2001 From: Eran Hammer Date: Thu, 1 Nov 2018 01:07:40 -0700 Subject: [PATCH] Cleanup and update deps. Closes #121 --- .gitignore | 23 +++++++---------------- .travis.yml | 3 ++- LICENSE | 6 +----- lib/fs.js | 6 +++--- package.json | 6 +++--- test/directory.js | 4 ++-- test/file.js | 31 ++++++++++++++++--------------- 7 files changed, 34 insertions(+), 45 deletions(-) diff --git a/.gitignore b/.gitignore index eb305a1..27dbfd0 100644 --- a/.gitignore +++ b/.gitignore @@ -1,18 +1,9 @@ -.idea -*.iml -npm-debug.log -dump.rdb -node_modules -results.tap -results.xml -config.json -.DS_Store -*/.DS_Store -*/*/.DS_Store -._* -*/._* -*/*/._* +**/node_modules +**/package-lock.json + coverage.* -.settings -package-lock.json +**/.DS_Store +**/._* + +**/*.pem diff --git a/.travis.yml b/.travis.yml index a3ed993..d5dd1e7 100755 --- a/.travis.yml +++ b/.travis.yml @@ -2,7 +2,8 @@ language: node_js node_js: - "8" - - "9" + - "10" + - "11" - "node" sudo: false diff --git a/LICENSE b/LICENSE index ed4573a..a7c4fb1 100755 --- a/LICENSE +++ b/LICENSE @@ -1,4 +1,4 @@ -Copyright (c) 2012-2017, Gil Pedersen and other contributors. +Copyright (c) 2012-2018, Gil Pedersen and other contributors. Copyright (c) 2012-2014, Walmart. All rights reserved. @@ -23,7 +23,3 @@ LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - - * * * - -The complete list of contributors can be found at: https://github.com/hapijs/inert/graphs/contributors diff --git a/lib/fs.js b/lib/fs.js index 3c6cede..807eccf 100755 --- a/lib/fs.js +++ b/lib/fs.js @@ -2,6 +2,7 @@ // Load modules +const Fs = require('fs'); const Util = require('util'); const Boom = require('boom'); @@ -106,13 +107,12 @@ exports.File.prototype.createReadStream = function (options) { // Export Fs methods -const NodeFs = require('fs'); for (let i = 0; i < internals.methods.raw.length; ++i) { const method = internals.methods.raw[i]; - exports[method] = NodeFs[method].bind(NodeFs); + exports[method] = Fs[method].bind(Fs); } for (let i = 0; i < internals.methods.promised.length; ++i) { const method = internals.methods.promised[i]; - exports[method] = Util.promisify(NodeFs[method]); + exports[method] = Util.promisify(Fs[method]); } diff --git a/package.json b/package.json index 75517b7..96d9590 100644 --- a/package.json +++ b/package.json @@ -21,14 +21,14 @@ "ammo": "3.x.x", "boom": "7.x.x", "bounce": "1.x.x", - "hoek": "5.x.x", - "joi": "13.x.x", + "hoek": "6.x.x", + "joi": "14.x.x", "lru-cache": "4.1.x" }, "devDependencies": { "code": "5.x.x", "hapi": "17.x.x", - "lab": "15.x.x" + "lab": "17.x.x" }, "scripts": { "test": "lab -f -a code -t 100 -L", diff --git a/test/directory.js b/test/directory.js index 14ffaab..9294f9f 100755 --- a/test/directory.js +++ b/test/directory.js @@ -737,10 +737,10 @@ describe('directory', () => { const orig = InertFs.fstat; let callCnt = 0; - InertFs.fstat = function () { + InertFs.fstat = function (...args) { callCnt++; - return orig.apply(InertFs, arguments); + return orig.apply(InertFs, args); }; const server = await provisionServer(); diff --git a/test/file.js b/test/file.js index dd3ad70..52bff75 100755 --- a/test/file.js +++ b/test/file.js @@ -441,7 +441,7 @@ describe('file', () => { expect(res2.headers).to.include('last-modified'); const fd1 = Fs.openSync(Path.join(__dirname, 'file', 'note.txt'), 'w'); - Fs.writeSync(fd1, new Buffer('Test'), 0, 4); + Fs.writeSync(fd1, Buffer.from('Test'), 0, 4); Fs.closeSync(fd1); // etag after file modified, content unchanged @@ -455,7 +455,7 @@ describe('file', () => { expect(etag1).to.not.equal(etag2); const fd2 = Fs.openSync(Path.join(__dirname, 'file', 'note.txt'), 'w'); - Fs.writeSync(fd2, new Buffer('Test1'), 0, 5); + Fs.writeSync(fd2, Buffer.from('Test1'), 0, 5); Fs.closeSync(fd2); // etag after file modified, content changed @@ -471,7 +471,7 @@ describe('file', () => { expect(etag2).to.not.equal(etag3); const fd3 = Fs.openSync(Path.join(__dirname, 'file', 'note.txt'), 'w'); - Fs.writeSync(fd3, new Buffer('Test'), 0, 4); + Fs.writeSync(fd3, Buffer.from('Test'), 0, 4); Fs.closeSync(fd3); }); @@ -502,7 +502,7 @@ describe('file', () => { Fs.unlinkSync(Path.join(__dirname, 'file', 'note.txt')); const fd1 = Fs.openSync(Path.join(__dirname, 'file', 'note.txt'), 'w'); - Fs.writeSync(fd1, new Buffer('Test'), 0, 4); + Fs.writeSync(fd1, Buffer.from('Test'), 0, 4); Fs.closeSync(fd1); // etag after file modified, content unchanged @@ -516,7 +516,7 @@ describe('file', () => { expect(etag1).to.equal(etag2); const fd2 = Fs.openSync(Path.join(__dirname, 'file', 'note.txt'), 'w'); - Fs.writeSync(fd2, new Buffer('Test1'), 0, 5); + Fs.writeSync(fd2, Buffer.from('Test1'), 0, 5); Fs.closeSync(fd2); // etag after file modified, content changed @@ -530,7 +530,7 @@ describe('file', () => { expect(etag1).to.not.equal(etag3); const fd3 = Fs.openSync(Path.join(__dirname, 'file', 'note.txt'), 'w'); - Fs.writeSync(fd3, new Buffer('Test'), 0, 4); + Fs.writeSync(fd3, Buffer.from('Test'), 0, 4); Fs.closeSync(fd3); // etag, content restored @@ -1141,6 +1141,7 @@ describe('file', () => { err.code = 'EACCES'; err.errno = -13; } + throw err; } }; @@ -1172,7 +1173,7 @@ describe('file', () => { expect(res.headers['content-length']).to.equal(5); expect(res.headers['content-range']).to.equal('bytes 0-4/42010'); expect(res.headers['accept-ranges']).to.equal('bytes'); - expect(res.rawPayload).to.equal(new Buffer('\x89PNG\r', 'ascii')); + expect(res.rawPayload).to.equal(Buffer.from('\x89PNG\r', 'ascii')); }); it('returns a subset of a file (middle)', async () => { @@ -1185,7 +1186,7 @@ describe('file', () => { expect(res.headers['content-length']).to.equal(5); expect(res.headers['content-range']).to.equal('bytes 1-5/42010'); expect(res.headers['accept-ranges']).to.equal('bytes'); - expect(res.rawPayload).to.equal(new Buffer('PNG\r\n', 'ascii')); + expect(res.rawPayload).to.equal(Buffer.from('PNG\r\n', 'ascii')); }); it('returns a subset of a file (-to)', async () => { @@ -1198,7 +1199,7 @@ describe('file', () => { expect(res.headers['content-length']).to.equal(5); expect(res.headers['content-range']).to.equal('bytes 42005-42009/42010'); expect(res.headers['accept-ranges']).to.equal('bytes'); - expect(res.rawPayload).to.equal(new Buffer('D\xAEB\x60\x82', 'ascii')); + expect(res.rawPayload).to.equal(Buffer.from('D\xAEB\x60\x82', 'ascii')); }); it('returns a subset of a file (from-)', async () => { @@ -1211,7 +1212,7 @@ describe('file', () => { expect(res.headers['content-length']).to.equal(5); expect(res.headers['content-range']).to.equal('bytes 42005-42009/42010'); expect(res.headers['accept-ranges']).to.equal('bytes'); - expect(res.rawPayload).to.equal(new Buffer('D\xAEB\x60\x82', 'ascii')); + expect(res.rawPayload).to.equal(Buffer.from('D\xAEB\x60\x82', 'ascii')); }); it('returns a subset of a file (beyond end)', async () => { @@ -1224,7 +1225,7 @@ describe('file', () => { expect(res.headers['content-length']).to.equal(5); expect(res.headers['content-range']).to.equal('bytes 42005-42009/42010'); expect(res.headers['accept-ranges']).to.equal('bytes'); - expect(res.rawPayload).to.equal(new Buffer('D\xAEB\x60\x82', 'ascii')); + expect(res.rawPayload).to.equal(Buffer.from('D\xAEB\x60\x82', 'ascii')); }); it('returns a subset of a file (if-range)', async () => { @@ -1238,7 +1239,7 @@ describe('file', () => { expect(res2.headers['content-length']).to.equal(5); expect(res2.headers['content-range']).to.equal('bytes 42005-42009/42010'); expect(res2.headers['accept-ranges']).to.equal('bytes'); - expect(res2.rawPayload).to.equal(new Buffer('D\xAEB\x60\x82', 'ascii')); + expect(res2.rawPayload).to.equal(Buffer.from('D\xAEB\x60\x82', 'ascii')); }); it('returns 200 on incorrect if-range', async () => { @@ -1322,7 +1323,7 @@ describe('file', () => { expect(res.headers['content-length']).to.equal(4); expect(res.headers['content-range']).to.equal('bytes 1-4/42010'); expect(res.headers['accept-ranges']).to.equal('bytes'); - expect(res.rawPayload).to.equal(new Buffer('PNG\r', 'ascii')); + expect(res.rawPayload).to.equal(Buffer.from('PNG\r', 'ascii')); expect(createOptions).to.include({ start: 1, end: 4 }); }); @@ -1439,7 +1440,7 @@ describe('file', () => { expect(res.headers['content-length']).to.equal(2); expect(res.headers['content-range']).to.equal('bytes 2-3/42009'); expect(res.headers['accept-ranges']).to.equal('bytes'); - expect(res.rawPayload).to.equal(new Buffer('G\r', 'ascii')); + expect(res.rawPayload).to.equal(Buffer.from('G\r', 'ascii')); }); it('returns a subset of a file with start and end option', async () => { @@ -1460,7 +1461,7 @@ describe('file', () => { expect(res.headers['content-length']).to.equal(3); expect(res.headers['content-range']).to.equal('bytes 0-2/399'); expect(res.headers['accept-ranges']).to.equal('bytes'); - expect(res.rawPayload).to.equal(new Buffer('NG\r', 'ascii')); + expect(res.rawPayload).to.equal(Buffer.from('NG\r', 'ascii')); }); });