Skip to content

Commit

Permalink
⭐add some new path to create schema of declaration
Browse files Browse the repository at this point in the history
  • Loading branch information
etefaghian committed Jun 13, 2021
1 parent 07961c2 commit df59d08
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 2 deletions.
12 changes: 10 additions & 2 deletions declarations/schema/mod.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { Project, log, emptyDir } from "../../deps.ts";
import { rgb24 } from "https://deno.land/[email protected]/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) => {
Expand All @@ -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`,
Expand Down
1 change: 1 addition & 0 deletions declarations/utils/mod.ts
Original file line number Diff line number Diff line change
@@ -1 +1,2 @@
export * from "./denoResolutionHost.ts";
export * from "./throwError.ts";
3 changes: 3 additions & 0 deletions declarations/utils/throwError.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
export const throwError = (msg?: string) => {
throw new Error(msg);
};

0 comments on commit df59d08

Please sign in to comment.