Skip to content

Commit

Permalink
feat: resolve relative paths
Browse files Browse the repository at this point in the history
  • Loading branch information
buttercubz committed Mar 4, 2021
1 parent 44aefc7 commit b86444d
Show file tree
Hide file tree
Showing 4 changed files with 20 additions and 4 deletions.
12 changes: 12 additions & 0 deletions imports/deps.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
{
"meta": {
"gql": {
"url": "https://cdn.skypack.dev/graphql-tag@2.10.1",
"hash": "c7a4e598d237cd8cc2c5d1eb7eb4df67eb0a5e86c34fabf61b9b45e33df3e726"
},
"path": {
"url": "https://deno.land/std/path/mod.ts",
"hash": "7785d20e2d17f5b217f1f5120bc47adcde3854060e7be740bb8bd539c083020f"
}
}
}
3 changes: 3 additions & 0 deletions imports/gql.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
import gql from "https://cdn.skypack.dev/graphql-tag@2.10.1";

export { gql };
1 change: 1 addition & 0 deletions imports/path.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
export * from "https://deno.land/std/path/mod.ts";
8 changes: 4 additions & 4 deletions mod.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import gql from "https://cdn.pika.dev/graphql-tag@^2.10.1";
import { red } from "https://deno.land/std/fmt/colors.ts";
import { join } from "./imports/path.ts";
import { gql } from "./imports/gql.ts";

const { readFileSync } = Deno;
/**
Expand All @@ -14,13 +14,13 @@ export function importQL(path: string): object {

try {
const decoder = new TextDecoder("utf-8");
const file = readFileSync(path);
const file = readFileSync(join(Deno.cwd(), path));
// @ts-ignore
return gql`
${decoder.decode(file)}
`;
} catch (error) {
console.error(new Error(`file [${red(path)}] not found`));
console.error(new Error(`error parsing file [${path}]`));
return {};
}
}

0 comments on commit b86444d

Please sign in to comment.