Skip to content

Commit e9e4981

Browse files
authored
Merge pull request #39 from GuentherJulian/feature/assertionDirectoryNotEmpty
WIP: assertion directoryNotEmpty
2 parents 685f03d + c6dd507 commit e9e4981

File tree

2 files changed

+15
-0
lines changed

2 files changed

+15
-0
lines changed

assertions/directoryNotEmpty.ts

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
import * as fs from "fs";
2+
3+
export class DirectoryNotEmpty {
4+
public static run(directory: string): void {
5+
if(fs.readdirSync(directory).length == 0) {
6+
throw new Error("directory " + directory + " is empty");
7+
}
8+
}
9+
}

assertions/index.ts

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ import { NoErrorCode } from "./noErrorCode";
55
import { NoException } from "./noException";
66
import { DirectoryExist } from "./directoryExist";
77
import { FileExist } from "./fileExist";
8+
import { DirectoryNotEmpty } from "./directoryNotEmpty";
89

910

1011
export class Assertions {
@@ -24,6 +25,11 @@ export class Assertions {
2425
return this;
2526
}
2627

28+
public directoryNotEmpty(directory: string): Assertions {
29+
DirectoryNotEmpty.run(directory);
30+
return this;
31+
}
32+
2733
public fileExits(filepath: string): Assertions {
2834
FileExist.run(filepath);
2935
return this;

0 commit comments

Comments
 (0)