Skip to content

Commit

Permalink
Add test
Browse files Browse the repository at this point in the history
  • Loading branch information
rix0rrr committed Nov 13, 2020
1 parent 2ed519f commit 7676810
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 2 deletions.
4 changes: 2 additions & 2 deletions packages/@aws-cdk/pipelines/lib/private/fs.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ import * as path from 'path';
* Relevant if the current system is a Windows machine but is generating
* commands for a Linux CodeBuild image.
*/
export function toPosixPath(osPath: string) {
const regex = new RegExp(`\\${path.sep}`, 'g');
export function toPosixPath(osPath: string, currentSep?: string) {
const regex = new RegExp(`\\${currentSep ?? path.sep}`, 'g');
return osPath.replace(regex, '/');
}
11 changes: 11 additions & 0 deletions packages/@aws-cdk/pipelines/test/fs.test.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
import * as path from 'path';
import { toPosixPath } from '../lib/private/fs';

test('translate path.sep', () => {
expect(toPosixPath(`a${path.sep}b${path.sep}c`)).toEqual('a/b/c');
});

test('windows path to posix path', () => {
const winPath = path.win32.join('a', 'b', 'c');
expect(toPosixPath(winPath, path.win32.sep)).toEqual('a/b/c');
});

0 comments on commit 7676810

Please sign in to comment.