Skip to content

Commit 33767d1

Browse files
committed
Fix sorting on Node <= 10
Related to 4bbcfdc.
1 parent a9ef345 commit 33767d1

File tree

3 files changed

+40
-0
lines changed

3 files changed

+40
-0
lines changed

package.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,7 @@
3939
"strip-ansi": "^5.0.0",
4040
"tape": "^4.0.0",
4141
"to-vfile": "^5.0.0",
42+
"vfile-sort": "^2.1.3",
4243
"xo": "^0.23.0"
4344
},
4445
"scripts": {

test/index.js

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ var execa = require('execa')
77
var vfile = require('to-vfile')
88
var remark = require('remark')
99
var strip = require('strip-ansi')
10+
var sort = require('./sort')
1011
var links = require('..')
1112

1213
process.chdir(path.resolve(process.cwd(), 'test', 'fixtures'))
@@ -23,6 +24,7 @@ test('remark-validate-links', function(t) {
2324

2425
remark()
2526
.use(links)
27+
.use(sort)
2628
.process(vfile.readSync('github.md'), function(err, file) {
2729
st.deepEqual(
2830
[err].concat(file.messages.map(String)),
@@ -40,6 +42,8 @@ test('remark-validate-links', function(t) {
4042
'--no-ignore',
4143
'--use',
4244
'../..=repository:"invalid:shortcode"',
45+
'--use',
46+
'../sort',
4347
'definitions.md'
4448
]).then(
4549
function() {
@@ -69,6 +73,8 @@ test('remark-validate-links', function(t) {
6973
'--no-ignore',
7074
'--use',
7175
'../..=repository:"gist:wooorm/8504606"',
76+
'--use',
77+
'../sort',
7278
'definitions.md'
7379
]).then(
7480
function() {
@@ -99,6 +105,8 @@ test('remark-validate-links', function(t) {
99105
'--use',
100106
'../..',
101107
'definitions.md',
108+
'--use',
109+
'../sort',
102110
'FOOOO'
103111
]).then(
104112
function() {
@@ -131,6 +139,8 @@ test('remark-validate-links', function(t) {
131139
'--no-ignore',
132140
'--use',
133141
'../..',
142+
'--use',
143+
'../sort',
134144
'github.md'
135145
]).then(function(result) {
136146
st.equal(
@@ -162,6 +172,8 @@ test('remark-validate-links', function(t) {
162172
'--no-ignore',
163173
'--use',
164174
'../..',
175+
'--use',
176+
'../sort',
165177
'github.md',
166178
'examples/github.md'
167179
]).then(function(result) {
@@ -201,6 +213,8 @@ test('remark-validate-links', function(t) {
201213
'--no-ignore',
202214
'--use',
203215
'../..',
216+
'--use',
217+
'../sort',
204218
'definitions.md'
205219
]).then(function(result) {
206220
st.equal(
@@ -224,6 +238,8 @@ test('remark-validate-links', function(t) {
224238
'--no-ignore',
225239
'--use',
226240
'../..=repository:"wooorm/test"',
241+
'--use',
242+
'../sort',
227243
'github.md',
228244
'examples/github.md'
229245
]).then(function(result) {
@@ -289,6 +305,8 @@ test('remark-validate-links', function(t) {
289305
'--no-ignore',
290306
'--use',
291307
'../..',
308+
'--use',
309+
'../sort',
292310
'github.md',
293311
'examples/github.md'
294312
]).then(
@@ -351,6 +369,8 @@ test('remark-validate-links', function(t) {
351369
'--no-ignore',
352370
'--use',
353371
'../..=repository:"gitlab:wooorm/test"',
372+
'--use',
373+
'../sort',
354374
'gitlab.md'
355375
]).then(function(result) {
356376
st.equal(
@@ -390,6 +410,8 @@ test('remark-validate-links', function(t) {
390410
'--no-ignore',
391411
'--use',
392412
'../..=repository:"bitbucket:wooorm/test"',
413+
'--use',
414+
'../sort',
393415
'bitbucket.md'
394416
]).then(function(result) {
395417
st.equal(
@@ -429,6 +451,8 @@ test('remark-validate-links', function(t) {
429451
'--no-ignore',
430452
'--use',
431453
'../..',
454+
'--use',
455+
'../sort',
432456
'suggestions.md'
433457
]).then(function(result) {
434458
st.equal(
@@ -453,6 +477,8 @@ test('remark-validate-links', function(t) {
453477
'--no-ignore',
454478
'--use',
455479
'../..=repository:"wooorm/test"',
480+
'--use',
481+
'../sort',
456482
'line-links.md'
457483
]).then(function(result) {
458484
st.equal(

test/sort.js

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
'use strict'
2+
3+
var vfileSort = require('vfile-sort')
4+
5+
module.exports = sort
6+
7+
function sort() {
8+
return transform
9+
}
10+
11+
function transform(tree, file) {
12+
vfileSort(file)
13+
}

0 commit comments

Comments
 (0)