@@ -2,28 +2,28 @@ import fs from 'node:fs'
22import path from 'node:path'
33import { test } from 'node:test'
44import assert from 'node:assert'
5- import tempy from 'tempy'
5+ import { temporaryDirectory } from 'tempy'
66import { makeEmptyDir , makeEmptyDirSync } from './index.js'
77
88test ( 'creates a new directory if it does not exist' , async ( ) => {
9- const dir = path . join ( tempy . directory ( ) , 'empty' )
9+ const dir = path . join ( temporaryDirectory ( ) , 'empty' )
1010 assert . strictEqual ( await makeEmptyDir ( dir ) , 'created' )
1111 assert . ok ( fs . existsSync ( dir ) )
1212} )
1313
1414test ( 'creates a new directory and its parent directory, when recursive is set to true' , async ( ) => {
15- const dir = path . join ( tempy . directory ( ) , 'empty/empty' )
15+ const dir = path . join ( temporaryDirectory ( ) , 'empty/empty' )
1616 assert . strictEqual ( await makeEmptyDir ( dir , { recursive : true } ) , 'created' )
1717 assert . ok ( fs . existsSync ( dir ) )
1818} )
1919
2020test ( 'fails if the parent directory does not exist and recursive is not set' , async ( ) => {
21- const dir = path . join ( tempy . directory ( ) , 'empty/empty' )
21+ const dir = path . join ( temporaryDirectory ( ) , 'empty/empty' )
2222 await assert . rejects ( makeEmptyDir ( dir ) )
2323} )
2424
2525test ( 'removes everything from an existing directory' , async ( ) => {
26- const dir = path . join ( tempy . directory ( ) , 'empty' )
26+ const dir = path . join ( temporaryDirectory ( ) , 'empty' )
2727 fs . mkdirSync ( path . join ( dir ) )
2828 const filePath = path . join ( dir , 'file' )
2929 fs . writeFileSync ( filePath , '' , 'utf8' )
@@ -33,24 +33,24 @@ test('removes everything from an existing directory', async () => {
3333} )
3434
3535test ( 'sync: creates a new directory if it does not exist' , ( ) => {
36- const dir = path . join ( tempy . directory ( ) , 'empty' )
36+ const dir = path . join ( temporaryDirectory ( ) , 'empty' )
3737 assert . strictEqual ( makeEmptyDirSync ( dir ) , 'created' )
3838 assert . ok ( fs . existsSync ( dir ) )
3939} )
4040
4141test ( 'sync: creates a new directory and its parent directory, when recursive is set to true' , ( ) => {
42- const dir = path . join ( tempy . directory ( ) , 'empty/empty' )
42+ const dir = path . join ( temporaryDirectory ( ) , 'empty/empty' )
4343 assert . strictEqual ( makeEmptyDirSync ( dir , { recursive : true } ) , 'created' )
4444 assert . ok ( fs . existsSync ( dir ) )
4545} )
4646
4747test ( 'sync: fails if the parent directory does not exist and recursive is not set' , ( ) => {
48- const dir = path . join ( tempy . directory ( ) , 'empty/empty' )
48+ const dir = path . join ( temporaryDirectory ( ) , 'empty/empty' )
4949 assert . throws ( ( ) => makeEmptyDirSync ( dir ) )
5050} )
5151
5252test ( 'sync: removes everything from an existing directory' , ( ) => {
53- const dir = path . join ( tempy . directory ( ) , 'empty' )
53+ const dir = path . join ( temporaryDirectory ( ) , 'empty' )
5454 fs . mkdirSync ( path . join ( dir ) )
5555 const filePath = path . join ( dir , 'file' )
5656 fs . writeFileSync ( filePath , '' , 'utf8' )
0 commit comments