1- const test = require ( "ava" ) ;
2- const path = require ( "path" ) ;
3- const fs = require ( "fs/promises" ) ;
4- const { rimraf } = require ( "rimraf" ) ;
5- const getCollectionNewestGitCommitDate = require ( "../src/getCollectionNewestGitCommitDate.js" ) ;
1+ import test from "ava" ;
2+ import { mkdir , writeFile } from "node:fs/promises" ;
3+ import path from "node:path" ;
4+ import { rimraf } from "rimraf" ;
5+ import { fileURLToPath } from "url" ;
6+ import { getCollectionNewestGitCommitDate } from "../index.js" ;
67
7- const outputBase = path . join ( "tests/output/" ) ;
8+ const __dirname = path . dirname ( fileURLToPath ( import . meta . url ) ) ;
89
910test ( "Get newest commit date of collection" , ( t ) => {
1011 const collection = [
@@ -23,15 +24,16 @@ test("Shouldn't get commit date from an empty collection", async (t) => {
2324} ) ;
2425
2526test ( "Shouldn't get commit date from collection of uncommited files" , async ( t ) => {
27+ const outputBase = path . join ( "tests/output/" ) ;
2628 const collection = [
2729 { inputPath : path . join ( outputBase , "test-01.md" ) } ,
2830 { inputPath : path . join ( outputBase , "test-02.md" ) } ,
2931 ] ;
3032
3133 await rimraf ( outputBase ) ;
3234
33- await fs . mkdir ( outputBase , { recursive : true } ) ;
34- await Promise . all ( collection . map ( ( p ) => fs . writeFile ( p . inputPath , "" ) ) ) ;
35+ await mkdir ( outputBase , { recursive : true } ) ;
36+ await Promise . all ( collection . map ( ( p ) => writeFile ( p . inputPath , "" ) ) ) ;
3537
3638 t . is ( getCollectionNewestGitCommitDate ( collection ) , undefined ) ;
3739
0 commit comments