diff --git a/assertions/directoryNotEmpty.ts b/assertions/directoryNotEmpty.ts new file mode 100644 index 00000000..2b9c33e3 --- /dev/null +++ b/assertions/directoryNotEmpty.ts @@ -0,0 +1,9 @@ +import * as fs from "fs"; + +export class DirectoryNotEmpty { + public static run(directory: string): void { + if(fs.readdirSync(directory).length == 0) { + throw new Error("directory " + directory + " is empty"); + } + } +} \ No newline at end of file diff --git a/assertions/index.ts b/assertions/index.ts index e1607dbf..691dbfbb 100644 --- a/assertions/index.ts +++ b/assertions/index.ts @@ -5,6 +5,7 @@ import { NoErrorCode } from "./noErrorCode"; import { NoException } from "./noException"; import { DirectoryExist } from "./directoryExist"; import { FileExist } from "./fileExist"; +import { DirectoryNotEmpty } from "./directoryNotEmpty"; export class Assertions { @@ -24,6 +25,11 @@ export class Assertions { return this; } + public directoryNotEmpty(directory: string): Assertions { + DirectoryNotEmpty.run(directory); + return this; + } + public fileExits(filepath: string): Assertions { FileExist.run(filepath); return this; diff --git a/documentation/Functions.md b/documentation/Functions.md index 2a520c97..9ef2396e 100644 --- a/documentation/Functions.md +++ b/documentation/Functions.md @@ -35,7 +35,7 @@ cobiGenJava("path/to/java/file/MyEntity.java",[1,3,5,6,8]) ### createDevon4jProject #### parameter -1. the project name +1. The project name #### example createDevon4jProject("cobigenexample") diff --git a/runners/console/index.ts b/runners/console/index.ts index 9864d107..bb1219db 100644 --- a/runners/console/index.ts +++ b/runners/console/index.ts @@ -104,7 +104,7 @@ export class Console extends Runner { } async assertCobiGenJava(step: Step, command: Command, result: RunResult) { - console.log("assertCobiGenJava"); + console.log("there is no assertion yet for the cobiGenJava command"); } async assertCreateDevon4jProject(step: Step, command: Command, result: RunResult) {