From 70084f83d5ccb9ce8288fc57dcd38976a3f48fbd Mon Sep 17 00:00:00 2001 From: Douglas Christopher Wilson Date: Tue, 7 Mar 2017 01:32:12 -0500 Subject: [PATCH] lint: use standard style in readme --- .travis.yml | 2 +- README.md | 13 ++++++++++--- package.json | 3 ++- 3 files changed, 13 insertions(+), 5 deletions(-) diff --git a/.travis.yml b/.travis.yml index a8e4744..2a3f87a 100644 --- a/.travis.yml +++ b/.travis.yml @@ -19,7 +19,7 @@ before_install: # Setup Node.js version-specific dependencies - "test $TRAVIS_NODE_VERSION != '0.6' || npm rm --save-dev istanbul" - "test $TRAVIS_NODE_VERSION != '0.8' || npm rm --save-dev istanbul" - - "test $(echo $TRAVIS_NODE_VERSION | cut -d'.' -f1) -ge 4 || npm rm --save-dev eslint eslint-config-standard eslint-plugin-promise eslint-plugin-standard" + - "test $(echo $TRAVIS_NODE_VERSION | cut -d'.' -f1) -ge 4 || npm rm --save-dev eslint eslint-config-standard eslint-plugin-markdown eslint-plugin-promise eslint-plugin-standard" # Update Node.js modules - "test ! -d node_modules || npm prune" - "test ! -d node_modules || npm rebuild" diff --git a/README.md b/README.md index 52f4953..eebef13 100644 --- a/README.md +++ b/README.md @@ -16,6 +16,8 @@ $ npm install content-disposition ## API + + ```js var contentDisposition = require('content-disposition') ``` @@ -26,6 +28,8 @@ Create an attachment `Content-Disposition` header value using the given file nam if supplied. The `filename` is optional and if no file name is desired, but you want to specify `options`, set `filename` to `undefined`. + + ```js res.setHeader('Content-Disposition', contentDisposition('∫ maths.pdf')) ``` @@ -66,8 +70,10 @@ it). The type is normalized to lower-case. ### contentDisposition.parse(string) + + ```js -var disposition = contentDisposition.parse('attachment; filename="EURO rates.txt"; filename*=UTF-8\'\'%e2%82%ac%20rates.txt'); +var disposition = contentDisposition.parse('attachment; filename="EURO rates.txt"; filename*=UTF-8\'\'%e2%82%ac%20rates.txt') ``` Parse a `Content-Disposition` header string. This automatically handles extended @@ -88,12 +94,13 @@ are shown for the string `'attachment; filename="EURO rates.txt"; filename*=UTF- ```js var contentDisposition = require('content-disposition') var destroy = require('destroy') +var fs = require('fs') var http = require('http') var onFinished = require('on-finished') var filePath = '/path/to/public/plans.pdf' -http.createServer(function onRequest(req, res) { +http.createServer(function onRequest (req, res) { // set headers res.setHeader('Content-Type', 'application/pdf') res.setHeader('Content-Disposition', contentDisposition(filePath)) @@ -101,7 +108,7 @@ http.createServer(function onRequest(req, res) { // send file var stream = fs.createReadStream(filePath) stream.pipe(res) - onFinished(res, function (err) { + onFinished(res, function () { destroy(stream) }) }) diff --git a/package.json b/package.json index 055fde3..8b5f978 100644 --- a/package.json +++ b/package.json @@ -14,6 +14,7 @@ "devDependencies": { "eslint": "3.17.1", "eslint-config-standard": "7.0.0", + "eslint-plugin-markdown": "1.0.0-beta.4", "eslint-plugin-promise": "3.5.0", "eslint-plugin-standard": "2.1.1", "istanbul": "0.4.5", @@ -29,7 +30,7 @@ "node": ">= 0.6" }, "scripts": { - "lint": "eslint .", + "lint": "eslint --plugin markdown --ext js,md .", "test": "mocha --reporter spec --bail --check-leaks test/", "test-cov": "istanbul cover node_modules/mocha/bin/_mocha -- --reporter dot --check-leaks test/", "test-travis": "istanbul cover node_modules/mocha/bin/_mocha --report lcovonly -- --reporter spec --check-leaks test/"