Skip to content

Commit 7623a22

Browse files
committed
Update dependencies
1 parent dbd589c commit 7623a22

File tree

4 files changed

+53
-43
lines changed

4 files changed

+53
-43
lines changed

index.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import path from 'path'
22
import gitDiffTree from 'git-diff-tree'
3-
import findUp from 'vfile-find-up'
3+
import {findUpOne} from 'vfile-find-up'
44

55
var own = {}.hasOwnProperty
66

@@ -48,7 +48,7 @@ export default function diff() {
4848
if (own.call(cache, base)) {
4949
tick(cache[base])
5050
} else {
51-
findUp.one('.git', file.dirname, ongit)
51+
findUpOne('.git', file.dirname, ongit)
5252
}
5353

5454
function ongit(error, git) {

package.json

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -33,19 +33,20 @@
3333
],
3434
"dependencies": {
3535
"git-diff-tree": "^1.0.0",
36-
"vfile-find-up": "^5.0.0"
36+
"vfile-find-up": "^6.0.0"
3737
},
3838
"devDependencies": {
3939
"c8": "^7.0.0",
40-
"nlcst-to-string": "^2.0.0",
40+
"nlcst-to-string": "^3.0.0",
4141
"prettier": "^2.0.0",
4242
"remark-cli": "^9.0.0",
4343
"remark-preset-wooorm": "^8.0.0",
44-
"retext": "^7.0.0",
45-
"rimraf": "^3.0.0",
44+
"retext-english": "^3.0.0",
45+
"retext-stringify": "^2.0.0",
4646
"tape": "^5.0.0",
47-
"to-vfile": "^6.0.0",
48-
"unist-util-visit": "^2.0.0",
47+
"to-vfile": "^7.0.0",
48+
"unified": "^10.0.0-beta.1",
49+
"unist-util-visit": "^3.0.0",
4950
"xo": "^0.39.0"
5051
},
5152
"scripts": {

test/index.js

Lines changed: 33 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ import {promises as fsPromises} from 'fs'
33
import path from 'path'
44
import {promisify} from 'util'
55
import test from 'tape'
6-
import vfile from 'to-vfile'
6+
import {toVFile} from 'to-vfile'
77
import {processor} from './processor.js'
88

99
var exec = promisify(cp.exec)
@@ -43,7 +43,7 @@ test('diff() (travis)', function (t) {
4343
.then(() => exec('git config --global user.email').catch(setEmailAndName))
4444
// Add initial file.
4545
.then(() =>
46-
processor().process(vfile({path: 'example.txt', contents: stepOne}))
46+
processor().process(toVFile({path: 'example.txt', value: stepOne}))
4747
)
4848
.then((file) => {
4949
t.deepEqual(
@@ -52,7 +52,7 @@ test('diff() (travis)', function (t) {
5252
'should set messages'
5353
)
5454

55-
return vfile.write(file)
55+
return toVFile.write(file)
5656
})
5757
.then(() => exec('git add example.txt'))
5858
.then(() => exec('git commit -m one'))
@@ -61,16 +61,14 @@ test('diff() (travis)', function (t) {
6161
initial = result.stdout.trim()
6262
})
6363
// Change files.
64-
.then(() => vfile.write({path: 'example.txt', contents: stepTwo}))
64+
.then(() => toVFile.write({path: 'example.txt', value: stepTwo}))
6565
.then(() => exec('git add example.txt'))
6666
.then(() => exec('git commit -m two'))
6767
.then(() => exec('git rev-parse HEAD'))
6868
.then((result) => {
6969
final = result.stdout.trim()
7070
process.env.TRAVIS_COMMIT_RANGE = [initial, final].join('...')
71-
return processor().process(
72-
vfile({path: 'example.txt', contents: stepTwo})
73-
)
71+
return processor().process(toVFile({path: 'example.txt', value: stepTwo}))
7472
})
7573
.then((file) => {
7674
t.deepEqual(
@@ -81,7 +79,7 @@ test('diff() (travis)', function (t) {
8179
})
8280
// Again!
8381
.then(() =>
84-
processor().process(vfile({path: 'example.txt', contents: stepTwo}))
82+
processor().process(toVFile({path: 'example.txt', value: stepTwo}))
8583
)
8684
.then((file) => {
8785
t.deepEqual(
@@ -92,7 +90,7 @@ test('diff() (travis)', function (t) {
9290
})
9391
// Unstaged files.
9492
.then(() =>
95-
processor().process(vfile({path: 'missing.txt', contents: other}))
93+
processor().process(toVFile({path: 'missing.txt', value: other}))
9694
)
9795
.then((file) => {
9896
t.deepEqual(
@@ -102,8 +100,8 @@ test('diff() (travis)', function (t) {
102100
)
103101
})
104102
// New file.
105-
.then(() => vfile.write({path: 'example.txt', contents: stepThree}))
106-
.then(() => vfile.write({path: 'new.txt', contents: other}))
103+
.then(() => toVFile.write({path: 'example.txt', value: stepThree}))
104+
.then(() => toVFile.write({path: 'new.txt', value: other}))
107105
.then(() => exec('git add example.txt new.txt'))
108106
.then(() => exec('git commit -m three'))
109107
.then(() => exec('git rev-parse HEAD'))
@@ -113,7 +111,7 @@ test('diff() (travis)', function (t) {
113111
process.env.TRAVIS_COMMIT_RANGE = [initial, final].join('...')
114112

115113
return processor().process(
116-
vfile({path: 'example.txt', contents: stepThree})
114+
toVFile({path: 'example.txt', value: stepThree})
117115
)
118116
})
119117
.then((file) => {
@@ -123,7 +121,7 @@ test('diff() (travis)', function (t) {
123121
'should deal with multiple patches'
124122
)
125123

126-
return processor().process(vfile({path: 'new.txt', contents: other}))
124+
return processor().process(toVFile({path: 'new.txt', value: other}))
127125
})
128126
.then((file) => {
129127
t.deepEqual(
@@ -132,7 +130,7 @@ test('diff() (travis)', function (t) {
132130
'should deal with new files'
133131
)
134132

135-
return processor().process(vfile({path: 'new.txt', contents: other}))
133+
return processor().process(toVFile({path: 'new.txt', value: other}))
136134
})
137135
// Restore
138136
.then(restore, restore)
@@ -141,12 +139,15 @@ test('diff() (travis)', function (t) {
141139
(error) => t.ifErr(error, 'should not fail')
142140
)
143141

144-
function restore() {
142+
function restore(error) {
145143
delete process.env.TRAVIS_COMMIT_RANGE
146-
return fsPromises
147-
.rm('.git', {recursive: true})
148-
.then(() => fsPromises.rm('new.txt'))
149-
.then(() => fsPromises.rm('example.txt'))
144+
return Promise.allSettled([
145+
fsPromises.rm('.git', {recursive: true, force: true}),
146+
fsPromises.rm('new.txt', {force: true}),
147+
fsPromises.rm('example.txt', {force: true})
148+
]).then(() => {
149+
if (error instanceof Error) throw error
150+
})
150151
}
151152
})
152153

@@ -166,19 +167,17 @@ test('diff() (GitHub Actions)', function (t) {
166167

167168
exec('git init')
168169
// Add initial file.
169-
.then(() => vfile.write({path: 'example.txt', contents: stepOne}))
170+
.then(() => toVFile.write({path: 'example.txt', value: stepOne}))
170171
.then(() => exec('git add example.txt'))
171172
.then(() => exec('git commit -m one'))
172173
// Change file.
173-
.then(() => vfile.write({path: 'example.txt', contents: stepTwo}))
174+
.then(() => toVFile.write({path: 'example.txt', value: stepTwo}))
174175
.then(() => exec('git add example.txt'))
175176
.then(() => exec('git commit -m two'))
176177
.then(() => exec('git rev-parse HEAD'))
177178
.then((result) => {
178179
process.env.GITHUB_SHA = result.stdout.trim()
179-
return processor().process(
180-
vfile({path: 'example.txt', contents: stepTwo})
181-
)
180+
return processor().process(toVFile({path: 'example.txt', value: stepTwo}))
182181
})
183182
.then((file) => {
184183
t.deepEqual(
@@ -194,10 +193,10 @@ test('diff() (GitHub Actions)', function (t) {
194193
exec('git checkout -b other-branch')
195194
})
196195
// Change file.
197-
.then(() => vfile.write({path: 'example.txt', contents: stepThree}))
196+
.then(() => toVFile.write({path: 'example.txt', value: stepThree}))
198197
.then(() => exec('git add example.txt'))
199198
.then(() => exec('git commit -m three'))
200-
.then(() => vfile.write({path: 'example.txt', contents: stepFour}))
199+
.then(() => toVFile.write({path: 'example.txt', value: stepFour}))
201200
.then(() => exec('git add example.txt'))
202201
.then(() => exec('git commit -m four'))
203202
.then(() => exec('git rev-parse HEAD'))
@@ -206,7 +205,7 @@ test('diff() (GitHub Actions)', function (t) {
206205
process.env.GITHUB_BASE_REF = 'refs/heads/' + main
207206
process.env.GITHUB_HEAD_REF = 'refs/heads/other-branch'
208207
return processor().process(
209-
vfile({path: 'example.txt', contents: stepFour})
208+
toVFile({path: 'example.txt', value: stepFour})
210209
)
211210
})
212211
.then((file) => {
@@ -223,13 +222,16 @@ test('diff() (GitHub Actions)', function (t) {
223222
(error) => t.ifErr(error, 'should not fail')
224223
)
225224

226-
function restore() {
225+
function restore(error) {
227226
delete process.env.GITHUB_SHA
228227
delete process.env.GITHUB_BASE_REF
229228
delete process.env.GITHUB_HEAD_REF
230-
return fsPromises
231-
.rm('.git', {recursive: true})
232-
.then(() => fsPromises.rm('example.txt'))
229+
return Promise.allSettled([
230+
fsPromises.rm('.git', {recursive: true, force: true}),
231+
fsPromises.rm('example.txt', {force: true})
232+
]).then(() => {
233+
if (error instanceof Error) throw error
234+
})
233235
}
234236
})
235237

test/processor.js

Lines changed: 11 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,16 @@
1-
import retext from 'retext'
2-
import visit from 'unist-util-visit'
3-
import toString from 'nlcst-to-string'
1+
import {unified} from 'unified'
2+
import retextEnglish from 'retext-english'
3+
import retextStringify from 'retext-stringify'
4+
import {visit} from 'unist-util-visit'
5+
import {toString} from 'nlcst-to-string'
46
import unifiedDiff from '../index.js'
57

6-
export const processor = retext().use(lorem).use(unifiedDiff).freeze()
8+
export const processor = unified()
9+
.use(retextEnglish)
10+
.use(retextStringify)
11+
.use(lorem)
12+
.use(unifiedDiff)
13+
.freeze()
714

815
function lorem() {
916
return transformer

0 commit comments

Comments
 (0)