Skip to content

Commit

Permalink
[Dev Deps] update eslint, @ljharb/eslint-config, tape; add `saf…
Browse files Browse the repository at this point in the history
…e-publish-latest`
  • Loading branch information
ljharb committed Jan 11, 2020
1 parent fc4188b commit 922abdf
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 23 deletions.
12 changes: 7 additions & 5 deletions package.json
Expand Up @@ -20,8 +20,9 @@
"license": "MIT",
"main": "index.js",
"scripts": {
"pretest": "npm run --silent lint",
"test": "npm run --silent tests-only",
"prepublish": "safe-publish-latest",
"pretest": "npm run lint",
"test": "npm run tests-only",
"tests-only": "node test",
"posttest": "npx aud",
"coverage": "covert test/index.js",
Expand Down Expand Up @@ -49,14 +50,15 @@
"safer-buffer": "^2.1.2"
},
"devDependencies": {
"@ljharb/eslint-config": "^14.1.0",
"@ljharb/eslint-config": "^15.1.0",
"covert": "^1.1.1",
"eslint": "^6.4.0",
"eslint": "^6.8.0",
"evalmd": "^0.0.19",
"foreach": "^2.0.5",
"has": "^1.0.3",
"object-keys": "^1.1.1",
"tape": "^4.11.0"
"safe-publish-latest": "^1.1.4",
"tape": "^5.0.0-next.3"
},
"engines": {
"node": ">= 0.4"
Expand Down
34 changes: 16 additions & 18 deletions test/index.js
Expand Up @@ -7,6 +7,7 @@ var forEach = require('foreach');
var keys = require('object-keys');
var Promise = require('promiseback').Deferred.Promise;
var has = require('has');
var assign = require('object.assign');

var noNewlineFilename = 'test/no-trailing-newline.json';
var testFilename = 'test/test.json';
Expand All @@ -30,6 +31,19 @@ var isFileNotFoundError = function (err) {
].indexOf(err.errno) > -1;
};

var enoent = function enoent(err, filename) {
var message = 'ENOENT' + (err.message.indexOf('no such file or directory') === 8 ? ': no such file or directory' : '') + ', open \'' + filename + "'";
var expectedError = assign(new Error(message), {
code: 'ENOENT',
errno: err.errno,
path: filename
});
if (has(err, 'syscall')) {
expectedError.syscall = 'open';
}
return expectedError;
};

test('requires a callback when arg is provided', function (t) {
t.plan(6);
t['throws'](function () { jsonFile(testFilename, undefined); }, TypeError, 'requires a function');
Expand All @@ -56,15 +70,7 @@ test('returns an exception if the file is not found', function (t) {
jsonFile('NOT A REAL FILE', function (err, file) {
t.ok(err, 'error is truthy');
t.ok(isFileNotFoundError(err), 'error number is correct');
var expectedError = {
code: 'ENOENT',
errno: err.errno,
path: path.resolve('NOT A REAL FILE')
};
if (has(err, 'syscall')) {
expectedError.syscall = 'open';
}
t.deepEqual(err, expectedError, 'returns an error');
t.deepEqual(err, enoent(err, path.resolve('NOT A REAL FILE')), 'returns an error');
t.equal(file, undefined, 'file is undefined');
t.end();
});
Expand Down Expand Up @@ -250,15 +256,7 @@ test('returns an error when no file', function (t) {
t.ok(err, 'error is truthy');
t.notOk(file, 'file is falsy');
t.ok(isFileNotFoundError(err), 'error number is correct');
var expectedError = {
code: 'ENOENT',
errno: err.errno,
path: filename
};
if (has(err, 'syscall')) {
expectedError.syscall = 'open';
}
t.deepEqual(err, expectedError, 'returned an error');
t.deepEqual(err, enoent(err, filename), 'returned an error');
t.end();
});
});
Expand Down

0 comments on commit 922abdf

Please sign in to comment.