File tree Expand file tree Collapse file tree 2 files changed +15
-0
lines changed Expand file tree Collapse file tree 2 files changed +15
-0
lines changed Original file line number Diff line number Diff line change 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+ }
Original file line number Diff line number Diff line change @@ -5,6 +5,7 @@ import { NoErrorCode } from "./noErrorCode";
55import { NoException } from "./noException" ;
66import { DirectoryExist } from "./directoryExist" ;
77import { FileExist } from "./fileExist" ;
8+ import { DirectoryNotEmpty } from "./directoryNotEmpty" ;
89
910
1011export 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 ;
You can’t perform that action at this time.
0 commit comments