Skip to content

Commit 00321e5

Browse files
Merge pull request #14 from GuentherJulian/feature_assertionFileExists
Created assertion fileExist
2 parents e416080 + 4e352a7 commit 00321e5

File tree

3 files changed

+15
-1
lines changed

3 files changed

+15
-1
lines changed

assertions/directoryExist.ts

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
import { RunResult } from "../engine/run_result";
21
import * as fs from "fs";
32

43
export class DirectoryExist {

assertions/fileExist.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 FileExist {
4+
public static run(filepath: string): void {
5+
if(!fs.existsSync(filepath)) {
6+
throw new Error("file " + filepath + " does not exist");
7+
}
8+
}
9+
}

assertions/index.ts

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ import { Command } from "../engine/command";
44
import { NoErrorCode } from "./noErrorCode";
55
import { NoException } from "./noException";
66
import { DirectoryExist } from "./directoryExist";
7+
import { FileExist } from "./fileExist";
78

89

910
export class Assertions {
@@ -22,4 +23,9 @@ export class Assertions {
2223
DirectoryExist.run(directory);
2324
return this;
2425
}
26+
27+
public fileExits(filepath: string): Assertions {
28+
FileExist.run(filepath);
29+
return this;
30+
}
2531
}

0 commit comments

Comments
 (0)