From c41acfbc76f5aa27fc27d93797b67b85fc65c53c Mon Sep 17 00:00:00 2001 From: coderaiser Date: Tue, 19 Jan 2021 14:13:07 +0200 Subject: [PATCH] feature(socket-file) drop support of node < 14 --- .eslintrc.json | 7 +++++-- .gitignore | 7 +++++-- .madrun.js => .madrun.mjs | 10 +++++----- .npmignore | 3 +-- .nycrc.json | 14 ++++++++++++++ .travis.yml | 16 ++++++---------- README.md | 21 ++++++++++----------- lib/socket-file.js | 4 ++-- package.json | 11 +++-------- test/socket-file.js | 6 +++++- 10 files changed, 56 insertions(+), 43 deletions(-) rename .madrun.js => .madrun.mjs (69%) create mode 100644 .nycrc.json diff --git a/.eslintrc.json b/.eslintrc.json index aa14888..d1e6136 100644 --- a/.eslintrc.json +++ b/.eslintrc.json @@ -1,7 +1,10 @@ { + "parserOptions": { + "ecmaVersion": 2021 + }, "extends": [ - "plugin:putout/recommended", - "plugin:node/recommended" + "plugin:node/recommended", + "plugin:putout/recommended" ], "plugins": [ "putout", diff --git a/.gitignore b/.gitignore index 0e37199..faf97a1 100644 --- a/.gitignore +++ b/.gitignore @@ -1,4 +1,7 @@ -node_modules -npm-debug.log +*.swp .nyc_output +.putoutcache +node_modules +npm-debug.log +yarn-error.log diff --git a/.madrun.js b/.madrun.mjs similarity index 69% rename from .madrun.js rename to .madrun.mjs index a925df1..c83e9d3 100644 --- a/.madrun.js +++ b/.madrun.mjs @@ -1,11 +1,11 @@ -'use strict'; +import {run} from 'madrun'; -const {run} = require('madrun'); - -module.exports = { +export default { 'test': () => 'tape test/**/*.js', 'watch:test': () => 'nodemon -w test -w lib --exec npm test', - 'lint': () => 'putout lib test .madrun.js', + 'lint': () => 'putout .', + 'fresh:lint': () => run('lint', '--fresh'), + 'lint:fresh': () => run('lint', '--fresh'), 'fix:lint': () => run('lint', '--fix'), 'lint:eslint:client': () => 'putout --config .putoutrc-client lib', 'lint:eslint:server': () => 'putout lib test', diff --git a/.npmignore b/.npmignore index c57de3d..6503225 100644 --- a/.npmignore +++ b/.npmignore @@ -1,5 +1,4 @@ .* test - -madrun.js +yarn-error.log diff --git a/.nycrc.json b/.nycrc.json new file mode 100644 index 0000000..1688bd8 --- /dev/null +++ b/.nycrc.json @@ -0,0 +1,14 @@ +{ + "check-coverage": false, + "all": false, + "exclude": [ + "**/*.spec.js", + "**/fixture", + "test", + ".*.{js,mjs}" + ], + "branches": 100, + "lines": 100, + "functions": 100, + "statements": 100 +} diff --git a/.travis.yml b/.travis.yml index 68b5eda..0861471 100644 --- a/.travis.yml +++ b/.travis.yml @@ -1,17 +1,13 @@ language: node_js node_js: - - 13 - - 12 - - 10 - + - 15 + - 14 script: - npm run lint - npm run coverage && npm run report - notifications: - email: - on_success: never - on_failure: change - + email: + on_success: never + on_failure: change sudo: false - +cache: false diff --git a/README.md b/README.md index cefa42c..b477e4a 100644 --- a/README.md +++ b/README.md @@ -27,9 +27,9 @@ socketFile(socket, { prefix: 'edward', root: '/', /* string or function */ size: '512000', /* max file size for patch */ - auth: (accept, reject) => (username, password) { + auth: (accept, reject) => (username, password) => { accept(); - } + }, }); ``` @@ -37,12 +37,11 @@ socketFile(socket, { MIT -[NPMIMGURL]: https://img.shields.io/npm/v/socket-file.svg?style=flat -[DependencyStatusIMGURL]: https://img.shields.io/david/coderaiser/node-socket-file.svg?style=flat -[LicenseIMGURL]: https://img.shields.io/badge/license-MIT-317BF9.svg?style=flat -[BuildStatusIMGURL]: https://img.shields.io/travis/coderaiser/node-socket-file/master.svg?style=flat -[NPMURL]: https://npmjs.org/package/socket-file "npm" -[DependencyStatusURL]: https://david-dm.org/coderaiser/node-socket-file "Dependency Status" -[LicenseURL]: https://tldrlegal.com/license/mit-license "MIT License" -[BuildStatusURL]: https://travis-ci.org/coderaiser/node-socket-file "Build Status" - +[NPMIMGURL]: https://img.shields.io/npm/v/socket-file.svg?style=flat +[DependencyStatusIMGURL]: https://img.shields.io/david/coderaiser/node-socket-file.svg?style=flat +[LicenseIMGURL]: https://img.shields.io/badge/license-MIT-317BF9.svg?style=flat +[BuildStatusIMGURL]: https://img.shields.io/travis/coderaiser/node-socket-file/master.svg?style=flat +[NPMURL]: https://npmjs.org/package/socket-file "npm" +[DependencyStatusURL]: https://david-dm.org/coderaiser/node-socket-file "Dependency Status" +[LicenseURL]: https://tldrlegal.com/license/mit-license "MIT License" +[BuildStatusURL]: https://travis-ci.org/coderaiser/node-socket-file "Build Status" diff --git a/lib/socket-file.js b/lib/socket-file.js index 147097d..f94cc5e 100644 --- a/lib/socket-file.js +++ b/lib/socket-file.js @@ -17,8 +17,8 @@ module.exports = (sock, options) => { if (!options) options = { - size : 512000, - root : '/', + size: 512_000, + root: '/', }; check(options.auth); diff --git a/package.json b/package.json index 15d084f..dce8cb2 100644 --- a/package.json +++ b/package.json @@ -13,12 +13,6 @@ "coverage": "madrun coverage", "report": "madrun report" }, - "nyc": { - "exclude": [ - "**/*.spec.js", - "test" - ] - }, "repository": { "type": "git", "url": "git://github.com/coderaiser/node-socket-file.git" @@ -52,9 +46,10 @@ "putout": "^13.7.1", "socket.io": "^3.1.0", "socket.io-client": "^3.1.0", - "supertape": "^4.7.0" + "supertape": "^4.7.0", + "try-catch": "^3.0.0" }, "engines": { - "node": ">=10.0.0" + "node": ">=14" } } diff --git a/test/socket-file.js b/test/socket-file.js index 3c84f9b..4cf44c1 100644 --- a/test/socket-file.js +++ b/test/socket-file.js @@ -1,5 +1,7 @@ 'use strict'; +const tryCatch = require('try-catch'); + const test = require('supertape'); const socketFile = require('..'); const connect = require('./connect')('socket-file', socketFile); @@ -46,7 +48,9 @@ test('socket-file: options: auth not function', (t) => { }); }; - t.throws(fn, /auth should be function!/, 'should throw when auth not function'); + const [error] = tryCatch(fn); + + t.equal(error.message, 'auth should be function!', 'should throw when auth not function'); t.end(); });