File tree 1 file changed +3
-8
lines changed
1 file changed +3
-8
lines changed Original file line number Diff line number Diff line change 1
1
// General helpers for dealing with markdown files / content.
2
2
3
- function removeTrailingNewline ( str : string ) {
4
- return str . replace ( / \s + $ / , '' ) ;
5
- }
6
-
7
3
export async function format ( str : string , filePath : string ) : Promise < string > {
8
4
try {
9
5
const { default : prettier } = await import ( 'prettier' ) ;
10
6
const options = await prettier . resolveConfig ( filePath ) ;
11
- // Trim the ending newline that prettier may add.
12
- return removeTrailingNewline (
13
- prettier . format ( str , {
7
+ return prettier
8
+ . format ( str , {
14
9
...options ,
15
10
parser : 'markdown' ,
16
11
} )
17
- ) ;
12
+ . trimEnd ( ) ; // Trim the ending newline that prettier may add.
18
13
} catch {
19
14
// Skip prettier formatting if not installed.
20
15
/* istanbul ignore next -- TODO: Figure out how to test when prettier is not installed. */
You can’t perform that action at this time.
0 commit comments