Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(pluginutils): normalizePath (#550)
* fix(pluginutils): normalize pattern sep * fix: missing quotes * doc: normalizePath * feat: normalizePath
- Loading branch information
Showing
7 changed files
with
74 additions
and
21 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
import { win32, posix } from 'path'; | ||
|
||
import { NormalizePath } from '../types'; | ||
|
||
const normalizePath: NormalizePath = function(filename: string) { | ||
return filename.split(win32.sep).join(posix.sep); | ||
}; | ||
|
||
export { normalizePath as default }; |
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,17 @@ | ||
import test from 'ava'; | ||
|
||
import { normalizePath } from '../'; | ||
|
||
test('replaces \\ with /', (t) => { | ||
t.is(normalizePath('foo\\bar'), 'foo/bar'); | ||
t.is(normalizePath('foo\\bar\\baz'), 'foo/bar/baz'); | ||
}); | ||
|
||
test('ignores forward slash', (t) => { | ||
t.is(normalizePath('foo/bar'), 'foo/bar'); | ||
t.is(normalizePath('foo/bar\\baz'), 'foo/bar/baz'); | ||
}); | ||
|
||
test('handles empty string', (t) => { | ||
t.is(normalizePath(''), ''); | ||
}); |
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