Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 10 additions & 0 deletions assertions/directoryExist.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
import { RunResult } from "../engine/run_result";
import * as fs from "fs";

export class DirectoryExist {
public static run(directory: string): void {
if(!fs.existsSync(directory)) {
throw new Error("directory " + directory + " does not exist");
}
}
}
8 changes: 7 additions & 1 deletion assertions/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,10 @@ import { Step } from "../engine/step";
import { Command } from "../engine/command";
import { NoErrorCode } from "./noErrorCode";
import { NoException } from "./noException";
import { DirectoryExist } from "./directoryExist";


export class Assertions{
export class Assertions {

public noErrorCode(result: RunResult): Assertions {
NoErrorCode.run(result);
Expand All @@ -16,4 +17,9 @@ export class Assertions{
NoException.run(result);
return this;
}

public directoryExits(directory: string): Assertions {
DirectoryExist.run(directory);
return this;
}
}
4 changes: 2 additions & 2 deletions assertions/noErrorCode.ts
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
import { RunResult } from "../engine/run_result";

export class NoErrorCode{
export class NoErrorCode {
public static run(result: RunResult): void {
if(result.returnCode != 0){
if(result.returnCode != 0) {
throw new Error("returnCode is not 0");
}
}
Expand Down
2 changes: 1 addition & 1 deletion assertions/noException.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import { RunResult } from "../engine/run_result";

export class NoException {
public static run(result: RunResult): void {
if(result.exceptions.length > 0){
if(result.exceptions.length > 0) {
throw new Error("Unexpected exception.");
}
}
Expand Down