Skip to content

Commit a2ba4ca

Browse files
committed
Merge tag 'v1.3.4'
2 parents dbaa56e + 0bb4608 commit a2ba4ca

File tree

15 files changed

+743
-544
lines changed

15 files changed

+743
-544
lines changed

.travis.yml

Lines changed: 76 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -7,26 +7,90 @@ node_js:
77
- "3.3"
88
- "4.9"
99
- "5.12"
10-
- "6.14"
10+
- "6.17"
1111
- "7.10"
12-
- "8.11"
12+
- "8.17"
1313
- "9.11"
14-
- "10.6"
14+
- "10.18"
15+
- "11.15"
16+
- "12.14"
17+
- "13.7"
1518
sudo: false
1619
cache:
1720
directories:
1821
- node_modules
1922
before_install:
20-
# Skip updating shrinkwrap / lock
21-
- "npm config set shrinkwrap false"
23+
- |
24+
# Setup utility functions
25+
function node_version_lt () {
26+
[[ "$(v "$TRAVIS_NODE_VERSION")" -lt "$(v "${1}")" ]]
27+
}
28+
function npm_module_installed () {
29+
npm -lsp ls | grep -Fq "$(pwd)/node_modules/${1}:${1}@"
30+
}
31+
function npm_remove_module_re () {
32+
node -e '
33+
fs = require("fs");
34+
p = JSON.parse(fs.readFileSync("package.json", "utf8"));
35+
r = RegExp(process.argv[1]);
36+
for (k in p.devDependencies) {
37+
if (r.test(k)) delete p.devDependencies[k];
38+
}
39+
fs.writeFileSync("package.json", JSON.stringify(p, null, 2) + "\n");
40+
' "$@"
41+
}
42+
function npm_use_module () {
43+
node -e '
44+
fs = require("fs");
45+
p = JSON.parse(fs.readFileSync("package.json", "utf8"));
46+
p.devDependencies[process.argv[1]] = process.argv[2];
47+
fs.writeFileSync("package.json", JSON.stringify(p, null, 2) + "\n");
48+
' "$@"
49+
}
50+
function v () {
51+
tr '.' '\n' <<< "${1}" \
52+
| awk '{ printf "%03d", $0 }' \
53+
| sed 's/^0*//'
54+
}
55+
# Configure npm
56+
- |
57+
# Skip updating shrinkwrap / lock
58+
npm config set shrinkwrap false
2259
# Setup Node.js version-specific dependencies
23-
- "test $(echo $TRAVIS_NODE_VERSION | cut -d. -f1) -ge 4 || npm rm --save-dev eslint eslint-plugin-markdown"
60+
- |
61+
# Configure eslint for linting
62+
if node_version_lt '8.0'; then npm_remove_module_re '^eslint(-|$)'
63+
fi
64+
- |
65+
# Configure mocha for testing
66+
if node_version_lt '4.0'; then npm_use_module 'mocha' '3.5.3'
67+
elif node_version_lt '6.0'; then npm_use_module 'mocha' '5.2.0'
68+
elif node_version_lt '8.0'; then npm_use_module 'mocha' '6.2.2'
69+
fi
70+
- |
71+
# Configure supertest for http calls
72+
if node_version_lt '4.0'; then npm_use_module 'supertest' '2.0.0'
73+
elif node_version_lt '6.0'; then npm_use_module 'supertest' '3.4.2'
74+
fi
2475
# Update Node.js modules
25-
- "test ! -d node_modules || npm prune"
26-
- "test ! -d node_modules || npm rebuild"
76+
- |
77+
# Prune and rebuild node_modules
78+
if [[ -d node_modules ]]; then
79+
npm prune
80+
npm rebuild
81+
fi
2782
script:
28-
# Run test script, then lint depending on eslint install
29-
- "npm run-script test-travis"
30-
- "test -z $(npm -ps ls eslint) || npm run-script lint"
83+
# Run test script
84+
- |
85+
npm test
86+
# Run linting, depending on eslint install
87+
- |
88+
if npm_module_installed 'eslint'; then npm run-script lint
89+
fi
3190
after_script:
32-
- "test -d .nyc_output && npm install coveralls@2 && nyc report --reporter=text-lcov | coveralls"
91+
# Upload coverage to coveralls if exists
92+
- |
93+
if [[ -d .nyc_output ]]; then
94+
npm install --save-dev coveralls@2
95+
nyc report --reporter=text-lcov | coveralls
96+
fi

HISTORY.md

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,10 @@
1+
2.x
2+
===
3+
4+
* deps: array-flatten@3.0.0
5+
* deps: parseurl@~1.3.3
6+
* deps: setprototypeof@1.2.0
7+
18
2.0.0-alpha.1 / 2018-07-27
29
==========================
310

@@ -11,6 +18,13 @@
1118
- Remove `DEBUG_FD` environment variable support
1219
- Support 256 namespace colors
1320

21+
1.3.4 / 2020-01-24
22+
==================
23+
24+
* deps: array-flatten@3.0.0
25+
* deps: parseurl@~1.3.3
26+
* deps: setprototypeof@1.2.0
27+
1428
1.3.3 / 2018-07-06
1529
==================
1630

README.md

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -175,14 +175,14 @@ rather than responding.
175175

176176
```js
177177
router.route('/')
178-
.all(function (req, res, next) {
179-
next()
180-
})
181-
.all(check_something)
182-
.get(function (req, res) {
183-
res.setHeader('Content-Type', 'text/plain; charset=utf-8')
184-
res.end('Hello World!')
185-
})
178+
.all(function (req, res, next) {
179+
next()
180+
})
181+
.all(check_something)
182+
.get(function (req, res) {
183+
res.setHeader('Content-Type', 'text/plain; charset=utf-8')
184+
res.end('Hello World!')
185+
})
186186
```
187187

188188
## Middleware

index.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@
1313
*/
1414

1515
var debug = require('debug')('router')
16-
var flatten = require('array-flatten')
16+
var flatten = require('array-flatten').flatten
1717
var Layer = require('./lib/layer')
1818
var methods = require('methods')
1919
var mixin = require('utils-merge')

lib/route.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@
1313
*/
1414

1515
var debug = require('debug')('router:route')
16-
var flatten = require('array-flatten')
16+
var flatten = require('array-flatten').flatten
1717
var Layer = require('./layer')
1818
var methods = require('methods')
1919

package.json

Lines changed: 11 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -9,22 +9,23 @@
99
"license": "MIT",
1010
"repository": "pillarjs/router",
1111
"dependencies": {
12-
"array-flatten": "2.1.1",
12+
"array-flatten": "3.0.0",
1313
"debug": "3.1.0",
1414
"methods": "~1.1.2",
15-
"parseurl": "~1.3.2",
15+
"parseurl": "~1.3.3",
1616
"path-to-regexp": "0.1.7",
17-
"setprototypeof": "1.1.0",
17+
"setprototypeof": "1.2.0",
1818
"utils-merge": "1.0.1"
1919
},
2020
"devDependencies": {
2121
"after": "0.8.2",
22-
"eslint": "3.19.0",
23-
"eslint-plugin-markdown": "1.0.0-beta.6",
24-
"finalhandler": "1.1.1",
25-
"mocha": "3.5.3",
22+
"eslint": "6.8.0",
23+
"eslint-plugin-markdown": "1.0.1",
24+
"finalhandler": "1.1.2",
25+
"mocha": "7.0.0",
2626
"nyc": "10.3.2",
27-
"supertest": "1.2.0"
27+
"safe-buffer": "5.2.0",
28+
"supertest": "4.0.2"
2829
},
2930
"files": [
3031
"lib/",
@@ -40,6 +41,7 @@
4041
"lint": "eslint --plugin markdown --ext js,md .",
4142
"test": "mocha --reporter spec --bail --check-leaks test/",
4243
"test-cov": "nyc --reporter=text npm test",
43-
"test-travis": "nyc --reporter=html --reporter=text npm test"
44+
"test-travis": "nyc --reporter=html --reporter=text npm test",
45+
"version": "node scripts/version-history.js && git add HISTORY.md"
4446
}
4547
}

scripts/version-history.js

Lines changed: 63 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,63 @@
1+
'use strict'
2+
3+
var fs = require('fs')
4+
var path = require('path')
5+
6+
var HISTORY_FILE_PATH = path.join(__dirname, '..', 'HISTORY.md')
7+
var MD_HEADER_REGEXP = /^====*$/
8+
var VERSION = process.env.npm_package_version
9+
var VERSION_PLACEHOLDER_REGEXP = /^(?:unreleased|(\d+\.)+x)$/
10+
11+
var historyFileLines = fs.readFileSync(HISTORY_FILE_PATH, 'utf-8').split('\n')
12+
13+
if (!MD_HEADER_REGEXP.test(historyFileLines[1])) {
14+
console.error('Missing header in HISTORY.md')
15+
process.exit(1)
16+
}
17+
18+
if (!VERSION_PLACEHOLDER_REGEXP.test(historyFileLines[0])) {
19+
console.error('Missing placeholder version in HISTORY.md')
20+
process.exit(1)
21+
}
22+
23+
if (historyFileLines[0].indexOf('x') !== -1) {
24+
var versionCheckRegExp = new RegExp('^' + historyFileLines[0].replace('x', '.+') + '$')
25+
26+
if (!versionCheckRegExp.test(VERSION)) {
27+
console.error('Version %s does not match placeholder %s', VERSION, historyFileLines[0])
28+
process.exit(1)
29+
}
30+
}
31+
32+
historyFileLines[0] = VERSION + ' / ' + getLocaleDate()
33+
historyFileLines[1] = repeat('=', historyFileLines[0].length)
34+
35+
fs.writeFileSync(HISTORY_FILE_PATH, historyFileLines.join('\n'))
36+
37+
function getLocaleDate () {
38+
var now = new Date()
39+
40+
return zeroPad(now.getFullYear(), 4) + '-' +
41+
zeroPad(now.getMonth() + 1, 2) + '-' +
42+
zeroPad(now.getDate(), 2)
43+
}
44+
45+
function repeat (str, length) {
46+
var out = ''
47+
48+
for (var i = 0; i < length; i++) {
49+
out += str
50+
}
51+
52+
return out
53+
}
54+
55+
function zeroPad (number, length) {
56+
var num = number.toString()
57+
58+
while (num.length < length) {
59+
num = '0' + num
60+
}
61+
62+
return num
63+
}

test/auto-head.js

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -13,10 +13,10 @@ describe('HEAD', function () {
1313
router.get('/users', sethit(1), saw)
1414

1515
request(server)
16-
.head('/users')
17-
.expect('Content-Type', 'text/plain')
18-
.expect('x-fn-1', 'hit')
19-
.expect(200, done)
16+
.head('/users')
17+
.expect('Content-Type', 'text/plain')
18+
.expect('x-fn-1', 'hit')
19+
.expect(200, done)
2020
})
2121

2222
it('should invoke head if prior to get', function (done) {
@@ -27,10 +27,10 @@ describe('HEAD', function () {
2727
router.get('/users', sethit(2), saw)
2828

2929
request(server)
30-
.head('/users')
31-
.expect('Content-Type', 'text/plain')
32-
.expect('x-fn-1', 'hit')
33-
.expect(200, done)
30+
.head('/users')
31+
.expect('Content-Type', 'text/plain')
32+
.expect('x-fn-1', 'hit')
33+
.expect(200, done)
3434
})
3535
})
3636

test/auto-options.js

Lines changed: 16 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -16,9 +16,9 @@ describe('OPTIONS', function () {
1616
router.put('/users', saw)
1717

1818
request(server)
19-
.options('/users')
20-
.expect('Allow', 'GET, HEAD, POST, PUT')
21-
.expect(200, 'GET, HEAD, POST, PUT', done)
19+
.options('/users')
20+
.expect('Allow', 'GET, HEAD, POST, PUT')
21+
.expect(200, 'GET, HEAD, POST, PUT', done)
2222
})
2323

2424
it('should not contain methods multiple times', function (done) {
@@ -31,9 +31,9 @@ describe('OPTIONS', function () {
3131
router.get('/users', saw)
3232

3333
request(server)
34-
.options('/users')
35-
.expect('GET, HEAD, PUT')
36-
.expect('Allow', 'GET, HEAD, PUT', done)
34+
.options('/users')
35+
.expect('GET, HEAD, PUT')
36+
.expect('Allow', 'GET, HEAD, PUT', done)
3737
})
3838

3939
it('should not include "all" routes', function (done) {
@@ -46,10 +46,10 @@ describe('OPTIONS', function () {
4646
router.all('/users', sethit(1))
4747

4848
request(server)
49-
.options('/users')
50-
.expect('x-fn-1', 'hit')
51-
.expect('Allow', 'GET, HEAD, PUT')
52-
.expect(200, 'GET, HEAD, PUT', done)
49+
.options('/users')
50+
.expect('x-fn-1', 'hit')
51+
.expect('Allow', 'GET, HEAD, PUT')
52+
.expect(200, 'GET, HEAD, PUT', done)
5353
})
5454

5555
it('should not respond if no matching path', function (done) {
@@ -59,8 +59,8 @@ describe('OPTIONS', function () {
5959
router.get('/users', saw)
6060

6161
request(server)
62-
.options('/')
63-
.expect(404, done)
62+
.options('/')
63+
.expect(404, done)
6464
})
6565

6666
it('should do nothing with explicit options route', function (done) {
@@ -71,8 +71,8 @@ describe('OPTIONS', function () {
7171
router.options('/users', saw)
7272

7373
request(server)
74-
.options('/users')
75-
.expect(200, 'saw OPTIONS /users', done)
74+
.options('/users')
75+
.expect(200, 'saw OPTIONS /users', done)
7676
})
7777

7878
describe('when error occurs in respone handler', function () {
@@ -88,8 +88,8 @@ describe('OPTIONS', function () {
8888
router.get('/users', saw)
8989

9090
request(server)
91-
.options('/users')
92-
.expect(200, 'true', done)
91+
.options('/users')
92+
.expect(200, 'true', done)
9393
})
9494
})
9595
})

0 commit comments

Comments
 (0)