forked from umijs/umi
-
Notifications
You must be signed in to change notification settings - Fork 0
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
Showing
3 changed files
with
33 additions
and
0 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
import winEOL from './winEOL'; | ||
|
||
const isWindows = | ||
typeof process !== 'undefined' && process.platform === 'win32'; | ||
|
||
test('normal', () => { | ||
if (isWindows) { | ||
expect(winEOL('a \r\n b')).toEqual('a \n b'); | ||
expect(winEOL('成 \r\n b')).toEqual('成 \n b'); | ||
expect(winEOL('🍟 \r\n 🍔')).toEqual('🍟 \n 🍔'); | ||
} else { | ||
expect(winEOL('a \n b')).toEqual('a \n b'); | ||
expect(winEOL('成 \n b')).toEqual('成 \n b'); | ||
expect(winEOL('🍟 \n 🍔')).toEqual('🍟 \n 🍔'); | ||
} | ||
}); |
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,16 @@ | ||
// 在windows环境下,很多工具都会把换行符lf自动改成crlf | ||
// 为了测试精准需要将换行符转化一下 | ||
// https://github.com/cssmagic/blog/issues/22 | ||
|
||
/** | ||
* Convert Windows crlf to lf (\r\n to \n) | ||
* @param content | ||
*/ | ||
export default (content: string | undefined) => { | ||
const isWindows = | ||
typeof process !== 'undefined' && process.platform === 'win32'; | ||
if (typeof content !== 'string') { | ||
return content; | ||
} | ||
return isWindows ? content.replace(/\r/g, '') : content; | ||
}; |