Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
fb97b4e
commit f2e1420
Showing
5 changed files
with
347 additions
and
210 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,21 +1,21 @@ | ||
import { writeFileSync, statSync, readFileSync, unlink } from 'fs'; | ||
import { writeFile as fsWriteFile, stat as fsStat, readFile as fsReadFile, unlink as fsUnlink } from 'fs-extra'; | ||
|
||
export function writeSync(filepath: string, content: string) { | ||
return writeFileSync(filepath, content); | ||
export function writeFile(filepath: string, content: string) { | ||
return fsWriteFile(filepath, content); | ||
} | ||
|
||
export function readSync(filepath: string) { | ||
return readFileSync(filepath, 'utf-8'); | ||
export function readFile(filepath: string) { | ||
return fsReadFile(filepath, 'utf-8'); | ||
} | ||
|
||
export function fileExists(filePath: string): boolean { | ||
export async function fileExists(filePath: string): Promise<boolean> { | ||
try { | ||
return statSync(filePath).isFile(); | ||
return (await fsStat(filePath)).isFile(); | ||
} catch (err) { | ||
return false; | ||
} | ||
} | ||
|
||
export function unlinkFile(filePath: string, cb?: (err?: Error) => any): void { | ||
unlink(filePath, cb); | ||
fsUnlink(filePath, cb); | ||
} |
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
Oops, something went wrong.