From 5646436659602cffc048366d5bd38fa524533083 Mon Sep 17 00:00:00 2001 From: coderaiser Date: Thu, 5 Sep 2019 15:59:55 +0300 Subject: [PATCH] feature(serve-once) add madrun --- .eslintrc | 19 ------------------- .eslintrc.json | 10 ++++++++++ .eslintrc.test | 8 -------- .npmignore | 2 ++ .travis.yml | 2 +- lib/serve-once.js | 2 +- madrun.js | 14 ++++++++++++++ package.json | 25 ++++++++++++------------- test/serve-once.js | 7 +++---- 9 files changed, 43 insertions(+), 46 deletions(-) delete mode 100644 .eslintrc create mode 100644 .eslintrc.json delete mode 100644 .eslintrc.test create mode 100644 madrun.js diff --git a/.eslintrc b/.eslintrc deleted file mode 100644 index 9a99629..0000000 --- a/.eslintrc +++ /dev/null @@ -1,19 +0,0 @@ -{ - "env": { - "node": true - }, - "parserOptions": { - "ecmaVersion": 2018, - "sourceType": "module" - }, - "rules": { - "indent": ["error", 4] - }, - "extends": [ - "eslint:recommended", - "plugin:node/recommended" - ], - "plugins": [ - "node" - ] -} diff --git a/.eslintrc.json b/.eslintrc.json new file mode 100644 index 0000000..aa14888 --- /dev/null +++ b/.eslintrc.json @@ -0,0 +1,10 @@ +{ + "extends": [ + "plugin:putout/recommended", + "plugin:node/recommended" + ], + "plugins": [ + "putout", + "node" + ] +} diff --git a/.eslintrc.test b/.eslintrc.test deleted file mode 100644 index 9cc1aec..0000000 --- a/.eslintrc.test +++ /dev/null @@ -1,8 +0,0 @@ -{ - "rules": { - "node/no-unsupported-features": 0 - }, - "extends": [ - ".eslintrc", - ], -} diff --git a/.npmignore b/.npmignore index c6db01b..28d444e 100644 --- a/.npmignore +++ b/.npmignore @@ -3,3 +3,5 @@ test *.swp coverage +madrun.js + diff --git a/.travis.yml b/.travis.yml index 1cfc1ec..f957db4 100644 --- a/.travis.yml +++ b/.travis.yml @@ -1,6 +1,6 @@ language: node_js node_js: - - 11 + - 12 - 10 - 8 diff --git a/lib/serve-once.js b/lib/serve-once.js index 9462cbe..efebf9b 100644 --- a/lib/serve-once.js +++ b/lib/serve-once.js @@ -81,7 +81,7 @@ module.exports = (middle, options) => { return { request: req, serve: bind(serve, middle), - } + }; }; function check(middle) { diff --git a/madrun.js b/madrun.js new file mode 100644 index 0000000..6cfebc8 --- /dev/null +++ b/madrun.js @@ -0,0 +1,14 @@ +'use strict'; + +const {run} = require('madrun'); + +module.exports = { + 'test': () => 'tape test/*.js', + 'lint': () => 'putout lib test madrun.js', + 'fix:lint': () => run('lint', '--fix'), + 'watch:test': () => run('watcher', '"npm test"'), + 'watcher': () => 'nodemon -w lib -w test -x', + 'coverage': () => 'nyc npm test', + 'report': () => 'nyc report --reporter=text-lcov | coveralls', +}; + diff --git a/package.json b/package.json index 726dfb5..9eb839b 100644 --- a/package.json +++ b/package.json @@ -21,14 +21,13 @@ "url": "git://github.com/coderaiser/node-serve-once.git" }, "scripts": { - "test": "tape test/*.js", - "lint": "redrun lint:*", - "lint:lib": "eslint lib", - "lint:test": "eslint test -c .eslintrc.test", - "watch:test": "npm run watcher -- \"npm test\"", - "watcher": "nodemon -w lib -w test -x", - "coverage": "nyc npm test", - "report": "nyc report --reporter=text-lcov | coveralls" + "test": "madrun test", + "lint": "madrun lint", + "fix:lint": "madrun fix:lint", + "watch:test": "madrun watch:test", + "watcher": "madrun watcher", + "coverage": "madrun coverage", + "report": "madrun report" }, "dependencies": { "express": "^5.0.0-alpha.7", @@ -44,13 +43,13 @@ "coveralls": "^3.0.0", "eslint": "^6.3.0", "eslint-plugin-node": "^10.0.0", + "eslint-plugin-putout": "^2.0.0", + "madrun": "^3.0.1", "nodemon": "^1.11.0", "nyc": "^14.1.1", "pullout": "^3.0.0", - "redrun": "^7.0.0", - "rimraf": "^2.6.2", - "tape": "^4.2.0", - "try-catch": "^2.0.0", - "try-to-tape": "^1.0.0" + "putout": "^5.11.1", + "supertape": "^1.2.3", + "try-catch": "^2.0.0" } } diff --git a/test/serve-once.js b/test/serve-once.js index 77d39fc..75277d7 100644 --- a/test/serve-once.js +++ b/test/serve-once.js @@ -2,15 +2,14 @@ const fs = require('fs'); -const tryToTape = require('try-to-tape'); -const test = tryToTape(require('tape')); +const test = require('supertape'); const tryCatch = require('try-catch'); const pullout = require('pullout'); const serveOnce = require('..'); test('serve-once: no middleware', (t) => { - const [e] = tryCatch(serveOnce) + const [e] = tryCatch(serveOnce); t.equal(e.message, 'middleware should be a function!', 'should equal'); t.end(); @@ -161,7 +160,7 @@ test('serve-once: fetch: headers', async (t) => { const {request} = serveOnce(middleware); const {body} = await request.get('/', { headers: { - authorization: 'basic' + authorization: 'basic', }, type: 'json', });