Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
refactor: Call 'fs-extra' functions via proxies (#6683)
Co-authored-by: Rhys Arkins <rhys@arkins.net>
- Loading branch information
Showing
10 changed files
with
93 additions
and
20 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
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,72 @@ | ||
import * as fs from 'fs-extra'; | ||
import { MoveOptions, WriteFileOptions } from 'fs-extra'; | ||
|
||
// istanbul ignore next | ||
export function stat(path: string | Buffer): Promise<fs.Stats> { | ||
return fs.stat(path); | ||
} | ||
|
||
// istanbul ignore next | ||
export function chmod( | ||
path: string | Buffer, | ||
mode: string | number | ||
): Promise<void> { | ||
return fs.chmod(path, mode); | ||
} | ||
|
||
export async function readFile(fileName: string): Promise<Buffer>; | ||
export async function readFile( | ||
fileName: string, | ||
encoding: 'utf8' | ||
): Promise<string>; | ||
export async function readFile( | ||
fileName: string, | ||
encoding?: string | ||
): Promise<string | Buffer> { | ||
return fs.readFile(fileName, encoding); | ||
} | ||
|
||
// istanbul ignore next | ||
export async function writeFile( | ||
fileName: string, | ||
fileContent: string | ||
): Promise<void> { | ||
return fs.writeFile(fileName, fileContent); | ||
} | ||
|
||
// istanbul ignore next | ||
export async function outputFile( | ||
file: string, | ||
data: any, | ||
options?: WriteFileOptions | string | ||
): Promise<void> { | ||
return fs.outputFile(file, data, options); | ||
} | ||
|
||
export async function remove(dir: string): Promise<void> { | ||
return fs.remove(dir); | ||
} | ||
|
||
// istanbul ignore next | ||
export async function unlink(path: string | Buffer): Promise<void> { | ||
return fs.unlink(path); | ||
} | ||
|
||
// istanbul ignore next | ||
export async function exists(path: string): Promise<boolean> { | ||
return fs.pathExists(path); | ||
} | ||
|
||
// istanbul ignore next | ||
export async function pathExists(path: string): Promise<boolean> { | ||
return fs.pathExists(path); | ||
} | ||
|
||
// istanbul ignore next | ||
export function move( | ||
src: string, | ||
dest: string, | ||
options?: MoveOptions | ||
): Promise<void> { | ||
return fs.move(src, dest, options); | ||
} |
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