Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
refactor: fs.promises, move mkdir to writeoutputfile, Part 3 (#4376)
* refactor: simplify, add return type * use alias fs in tests * refactor: move mkdir to writeoutputfile * refactor: replace indexof with includes Co-authored-by: Lukas Taegert-Atkinson <lukastaegert@users.noreply.github.com>
- Loading branch information
1 parent
f420a01
commit d3ed80c
Showing
9 changed files
with
39 additions
and
44 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,7 +1,7 @@ | ||
import { throwNoFileSystem } from './error'; | ||
|
||
export const promises = { | ||
readFile: throwNoFileSystem('fs.readFile') | ||
mkdir: throwNoFileSystem('fs.mkdir'), | ||
readFile: throwNoFileSystem('fs.readFile'), | ||
writeFile: throwNoFileSystem('fs.writeFile') | ||
}; | ||
|
||
export const writeFile = throwNoFileSystem('fs.writeFile'); |
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,9 +1 @@ | ||
import { promises as fs } from 'fs'; | ||
import { dirname } from './path'; | ||
|
||
export * from 'fs'; | ||
|
||
export async function writeFile(dest: string, data: string | Uint8Array): Promise<void> { | ||
await fs.mkdir(dirname(dest), { recursive: true }); | ||
await fs.writeFile(dest, data); | ||
} |
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
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