@@ -2,25 +2,27 @@ import assert from "assert";
22import fs from "fs" ;
33import path from "path" ;
44import os from "os" ;
5- import { UpdateOrCreateGitignore } from "./index" ;
5+ import { updateOrCreateGitignore } from "./index" ;
66
77describe ( "update or create .gitignore" , ( ) => {
88 let tmpDir : string ;
9- afterEach ( ( ) => {
10- fs . rmSync ( tmpDir , { recursive : true , force : true } ) ;
11- } ) ;
9+ beforeEach ( ( ) => {
10+ tmpDir = fs . mkdtempSync ( path . join ( os . tmpdir ( ) , "test-gitignore" ) ) ;
11+ } ) ;
12+
13+ afterEach ( ( ) => {
14+ fs . rmSync ( tmpDir , { recursive : true , force : true } ) ;
15+ } ) ;
1216
1317 it ( ".gitignore file exists and is correctly updated with missing paths" , async ( ) => {
14- const { updateOrCreateGitignore } = await importIndex ;
1518 fs . writeFileSync ( path . join ( tmpDir , ".gitignore" ) , "existingpath/" ) ;
1619
1720 updateOrCreateGitignore ( tmpDir , [ "existingpath/" , "newpath/" ] ) ;
1821
1922 const gitignoreContent = fs . readFileSync ( path . join ( tmpDir , ".gitignore" ) , "utf-8" ) ;
20- assert . equal ( `existingpath/\nnewpath/\n ` , gitignoreContent ) ;
23+ assert . equal ( `existingpath/\nnewpath/` , gitignoreContent ) ;
2124 } ) ;
2225 it ( ".gitignore file does not exist and is created" , async ( ) => {
23- const { updateOrCreateGitignore } = await importIndex ;
2426 updateOrCreateGitignore ( tmpDir , [ "chickenpath/" , "newpath/" ] ) ;
2527 const gitignoreContent = fs . readFileSync ( path . join ( tmpDir , ".gitignore" ) , "utf-8" ) ;
2628 assert . equal ( `chickenpath/\nnewpath/` , gitignoreContent ) ;
0 commit comments