-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(useTemporaryDirectory): Implement automatic creation/removal of …
…temporary directories
- Loading branch information
1 parent
049b348
commit ec9de52
Showing
7 changed files
with
69 additions
and
45 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1 @@ | ||
export default 'Hello World!' | ||
export {default as useTemporaryDirectory} from './use-temporary-directory/index.js' |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
import fs from 'fs-extra' | ||
import tempy from 'tempy' | ||
|
||
export default async function (t) { | ||
const directory = tempy.directory() | ||
await fs.ensureDir(directory) | ||
t.teardown(async () => { | ||
await fs.remove(directory) | ||
}) | ||
return directory | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
import test from 'ava' | ||
import {promises as fs} from 'fs' | ||
import {useTemporaryDirectory} from '../index.js' | ||
|
||
test.serial('creating a directory', async (t) => { | ||
const directory = await useTemporaryDirectory(t) | ||
|
||
const stats = await fs.stat(directory) | ||
t.true(stats.isDirectory()) | ||
|
||
global.directory = directory | ||
}) | ||
|
||
test.serial('cleaning up the directory', async (t) => { | ||
await t.throwsAsync(fs.stat(global.directory)) | ||
}) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters