diff --git a/declarations/schema/mod.ts b/declarations/schema/mod.ts index 968cfc8f..675c2df2 100644 --- a/declarations/schema/mod.ts +++ b/declarations/schema/mod.ts @@ -1,6 +1,6 @@ import { Project, log, emptyDir } from "../../deps.ts"; import { rgb24 } from "https://deno.land/std@0.96.0/fmt/colors.ts"; -import { denoResolutionHost } from "../utils/mod.ts"; +import { denoResolutionHost, throwError } from "../utils/mod.ts"; import { addFunQLInterfaceToSourceFile } from "./utils/addInterfaceToSrcFile.ts"; export const getSchemaDeclarations = async (dirPath?: string) => { @@ -16,7 +16,15 @@ export const getSchemaDeclarations = async (dirPath?: string) => { //handle differentiate between schema and schemas const dir = project.getDirectory(`${__dirname}/schema`) || - project.getDirectory(`${__dirname}/schemas`); + project.getDirectory(`${__dirname}/schemas`) || + project.getDirectory(`${__dirname}/src/schemas`) || + project.getDirectory(`${__dirname}/src/schema`); + + //throws error if dir not found + !dir && + throwError( + "directory of schema was not found, please move your schemas to path ./src/schema(s) or ./schema(s)" + ); const createdSourceFile = project.createSourceFile( `${__dirname}/declarations/schema/schema.ts`, diff --git a/declarations/utils/mod.ts b/declarations/utils/mod.ts index a7a55b8f..ee30ec00 100644 --- a/declarations/utils/mod.ts +++ b/declarations/utils/mod.ts @@ -1 +1,2 @@ export * from "./denoResolutionHost.ts"; +export * from "./throwError.ts"; diff --git a/declarations/utils/throwError.ts b/declarations/utils/throwError.ts new file mode 100644 index 00000000..035e14f4 --- /dev/null +++ b/declarations/utils/throwError.ts @@ -0,0 +1,3 @@ +export const throwError = (msg?: string) => { + throw new Error(msg); +};