-
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): Return an object with useful methods
BREAKING CHANGE: useTemporaryDirectory() now returns an object instead of a string
- Loading branch information
1 parent
90871a1
commit fa4a320
Showing
4 changed files
with
37 additions
and
5 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
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,11 +1,23 @@ | ||
import * as path from 'path' | ||
import fs from 'fs-extra' | ||
import tempy from 'tempy' | ||
import stripIndent from 'strip-indent' | ||
|
||
export default async function (t) { | ||
const directory = tempy.directory() | ||
|
||
await fs.ensureDir(directory) | ||
t.teardown(async () => { | ||
await fs.remove(directory) | ||
}) | ||
return directory | ||
|
||
return { | ||
path: directory, | ||
async writeFile(filePath, fileContents) { | ||
await fs.writeFile( | ||
path.join(directory, filePath), | ||
stripIndent(fileContents.trim()) + '\n' | ||
) | ||
} | ||
} | ||
} |
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