Skip to content

Commit

Permalink
windows del fix
Browse files Browse the repository at this point in the history
  • Loading branch information
chrisblossom committed Oct 23, 2019
1 parent 358104c commit db8f2cd
Showing 1 changed file with 12 additions and 3 deletions.
15 changes: 12 additions & 3 deletions test/util.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,12 @@ import os from 'os';

const fs = jest.requireActual('fs');

function normalizeDirectorySlash(pathname: string): string {
const normalizeCrossPlatform = pathname.replace(/\\/g, '/');

return normalizeCrossPlatform;
}

class TempDir {
public dir: string;

Expand Down Expand Up @@ -73,7 +79,7 @@ class TempDir {
* Replace Windows backslash directory separators with forward slashes
* so expected paths will be consistent cross platform
*/
const normalizeCrossPlatform = relativePath.replace(/\\/g, '/');
const normalizeCrossPlatform = normalizeDirectorySlash(relativePath);

return normalizeCrossPlatform;
});
Expand All @@ -82,7 +88,7 @@ class TempDir {
}

public clean(): Array<string> {
const cleanPattern = this.absolutePath('**/*');
const cleanPattern = normalizeDirectorySlash(this.absolutePath('**/*'));
const removed = del.sync(cleanPattern, {
dot: true,
force: true,
Expand All @@ -92,7 +98,10 @@ class TempDir {
}

public deleteTempDir(): Array<string> {
const removed = del.sync(this.dir, { force: true, dot: true });
const removed = del.sync(normalizeDirectorySlash(this.dir), {
force: true,
dot: true,
});

return removed;
}
Expand Down

0 comments on commit db8f2cd

Please sign in to comment.