1- 'use strict'
2-
3- var cp = require ( 'child_process' )
4- var path = require ( 'path' )
5- var promisify = require ( 'util' ) . promisify
6- var test = require ( 'tape' )
7- var rimraf = promisify ( require ( 'rimraf' ) )
8- var vfile = require ( 'to-vfile' )
9- var processor = require ( './processor.js' ) ( )
1+ import cp from 'child_process'
2+ import { promises as fsPromises } from 'fs'
3+ import path from 'path'
4+ import { promisify } from 'util'
5+ import test from 'tape'
6+ import vfile from 'to-vfile'
7+ import { processor } from './processor.js'
108
119var exec = promisify ( cp . exec )
1210
@@ -45,7 +43,7 @@ test('diff() (travis)', function (t) {
4543 . then ( ( ) => exec ( 'git config --global user.email' ) . catch ( setEmailAndName ) )
4644 // Add initial file.
4745 . then ( ( ) =>
48- processor . process ( vfile ( { path : 'example.txt' , contents : stepOne } ) )
46+ processor ( ) . process ( vfile ( { path : 'example.txt' , contents : stepOne } ) )
4947 )
5048 . then ( ( file ) => {
5149 t . deepEqual (
@@ -70,7 +68,9 @@ test('diff() (travis)', function (t) {
7068 . then ( ( result ) => {
7169 final = result . stdout . trim ( )
7270 process . env . TRAVIS_COMMIT_RANGE = [ initial , final ] . join ( '...' )
73- return processor . process ( vfile ( { path : 'example.txt' , contents : stepTwo } ) )
71+ return processor ( ) . process (
72+ vfile ( { path : 'example.txt' , contents : stepTwo } )
73+ )
7474 } )
7575 . then ( ( file ) => {
7676 t . deepEqual (
@@ -81,7 +81,7 @@ test('diff() (travis)', function (t) {
8181 } )
8282 // Again!
8383 . then ( ( ) =>
84- processor . process ( vfile ( { path : 'example.txt' , contents : stepTwo } ) )
84+ processor ( ) . process ( vfile ( { path : 'example.txt' , contents : stepTwo } ) )
8585 )
8686 . then ( ( file ) => {
8787 t . deepEqual (
@@ -92,7 +92,7 @@ test('diff() (travis)', function (t) {
9292 } )
9393 // Unstaged files.
9494 . then ( ( ) =>
95- processor . process ( vfile ( { path : 'missing.txt' , contents : other } ) )
95+ processor ( ) . process ( vfile ( { path : 'missing.txt' , contents : other } ) )
9696 )
9797 . then ( ( file ) => {
9898 t . deepEqual (
@@ -112,7 +112,7 @@ test('diff() (travis)', function (t) {
112112
113113 process . env . TRAVIS_COMMIT_RANGE = [ initial , final ] . join ( '...' )
114114
115- return processor . process (
115+ return processor ( ) . process (
116116 vfile ( { path : 'example.txt' , contents : stepThree } )
117117 )
118118 } )
@@ -123,7 +123,7 @@ test('diff() (travis)', function (t) {
123123 'should deal with multiple patches'
124124 )
125125
126- return processor . process ( vfile ( { path : 'new.txt' , contents : other } ) )
126+ return processor ( ) . process ( vfile ( { path : 'new.txt' , contents : other } ) )
127127 } )
128128 . then ( ( file ) => {
129129 t . deepEqual (
@@ -132,7 +132,7 @@ test('diff() (travis)', function (t) {
132132 'should deal with new files'
133133 )
134134
135- return processor . process ( vfile ( { path : 'new.txt' , contents : other } ) )
135+ return processor ( ) . process ( vfile ( { path : 'new.txt' , contents : other } ) )
136136 } )
137137 // Restore
138138 . then ( restore , restore )
@@ -143,9 +143,10 @@ test('diff() (travis)', function (t) {
143143
144144 function restore ( ) {
145145 delete process . env . TRAVIS_COMMIT_RANGE
146- return rimraf ( '.git' )
147- . then ( ( ) => rimraf ( 'new.txt' ) )
148- . then ( ( ) => rimraf ( 'example.txt' ) )
146+ return fsPromises
147+ . rm ( '.git' , { recursive : true } )
148+ . then ( ( ) => fsPromises . rm ( 'new.txt' ) )
149+ . then ( ( ) => fsPromises . rm ( 'example.txt' ) )
149150 }
150151} )
151152
@@ -175,7 +176,9 @@ test('diff() (GitHub Actions)', function (t) {
175176 . then ( ( ) => exec ( 'git rev-parse HEAD' ) )
176177 . then ( ( result ) => {
177178 process . env . GITHUB_SHA = result . stdout . trim ( )
178- return processor . process ( vfile ( { path : 'example.txt' , contents : stepTwo } ) )
179+ return processor ( ) . process (
180+ vfile ( { path : 'example.txt' , contents : stepTwo } )
181+ )
179182 } )
180183 . then ( ( file ) => {
181184 t . deepEqual (
@@ -202,7 +205,9 @@ test('diff() (GitHub Actions)', function (t) {
202205 process . env . GITHUB_SHA = result . stdout . trim ( )
203206 process . env . GITHUB_BASE_REF = 'refs/heads/' + main
204207 process . env . GITHUB_HEAD_REF = 'refs/heads/other-branch'
205- return processor . process ( vfile ( { path : 'example.txt' , contents : stepFour } ) )
208+ return processor ( ) . process (
209+ vfile ( { path : 'example.txt' , contents : stepFour } )
210+ )
206211 } )
207212 . then ( ( file ) => {
208213 t . deepEqual (
@@ -222,7 +227,9 @@ test('diff() (GitHub Actions)', function (t) {
222227 delete process . env . GITHUB_SHA
223228 delete process . env . GITHUB_BASE_REF
224229 delete process . env . GITHUB_HEAD_REF
225- return rimraf ( '.git' ) . then ( ( ) => rimraf ( 'example.txt' ) )
230+ return fsPromises
231+ . rm ( '.git' , { recursive : true } )
232+ . then ( ( ) => fsPromises . rm ( 'example.txt' ) )
226233 }
227234} )
228235
0 commit comments