Skip to content

Commit

Permalink
Cleanup and update deps. Closes #121
Browse files Browse the repository at this point in the history
  • Loading branch information
hueniverse committed Nov 1, 2018
1 parent 84b50b4 commit dc47399
Show file tree
Hide file tree
Showing 7 changed files with 34 additions and 45 deletions.
23 changes: 7 additions & 16 deletions .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
3 changes: 2 additions & 1 deletion .travis.yml
Expand Up @@ -2,7 +2,8 @@ language: node_js

node_js:
- "8"
- "9"
- "10"
- "11"
- "node"

sudo: false
6 changes: 1 addition & 5 deletions 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.

Expand All @@ -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
6 changes: 3 additions & 3 deletions lib/fs.js
Expand Up @@ -2,6 +2,7 @@

// Load modules

const Fs = require('fs');
const Util = require('util');

const Boom = require('boom');
Expand Down Expand Up @@ -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]);
}
6 changes: 3 additions & 3 deletions package.json
Expand Up @@ -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",
Expand Down
4 changes: 2 additions & 2 deletions test/directory.js
Expand Up @@ -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();
Expand Down
31 changes: 16 additions & 15 deletions test/file.js
Expand Up @@ -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
Expand All @@ -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
Expand All @@ -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);
});

Expand Down Expand Up @@ -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
Expand All @@ -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
Expand All @@ -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
Expand Down Expand Up @@ -1141,6 +1141,7 @@ describe('file', () => {
err.code = 'EACCES';
err.errno = -13;
}

throw err;
}
};
Expand Down Expand Up @@ -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 () => {
Expand All @@ -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 () => {
Expand All @@ -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 () => {
Expand All @@ -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 () => {
Expand All @@ -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 () => {
Expand All @@ -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 () => {
Expand Down Expand Up @@ -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 });
});

Expand Down Expand Up @@ -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 () => {
Expand All @@ -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'));
});
});

Expand Down

0 comments on commit dc47399

Please sign in to comment.