-
-
Notifications
You must be signed in to change notification settings - Fork 110
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
refactor: add prettier-plugin-organize-imports
- Loading branch information
1 parent
dae3cf8
commit 82e1834
Showing
11 changed files
with
31 additions
and
30 deletions.
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
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 |
---|---|---|
@@ -1,13 +1,10 @@ | ||
import { promisify } from 'util'; | ||
import { readFile as fsReadFile } from 'fs'; | ||
import { promises as fs } from 'fs'; | ||
import iconv from 'iconv-lite'; | ||
|
||
const readFileAsync = promisify(fsReadFile); | ||
|
||
/** | ||
* Read a file synchronously with the given encoding, and return its content as a string. | ||
* Read a file with the given encoding, and return its content as a string. | ||
* | ||
* Uses iconv-lite to solve some issues with Windows encodings. | ||
*/ | ||
export const readFile = async (file: string, encoding: string = 'utf-8') => | ||
/utf-?8/i.test(encoding) ? readFileAsync(file, { encoding }) : iconv.decode(await readFileAsync(file), encoding); | ||
/utf-?8/i.test(encoding) ? fs.readFile(file, { encoding }) : iconv.decode(await fs.readFile(file), encoding); |
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