Skip to content

Commit

Permalink
chore: fix types
Browse files Browse the repository at this point in the history
  • Loading branch information
jchip committed Aug 7, 2021
1 parent b7cda75 commit 2581908
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 10 deletions.
2 changes: 1 addition & 1 deletion packages/xarc-render-context/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@
],
"dependencies": {
"munchy": "^1.0.9",
"optional-require": "^1.0.2",
"optional-require": "^1.1.4",
"require-at": "^1.0.6",
"xaa": "^1.5.0"
},
Expand Down
15 changes: 6 additions & 9 deletions packages/xarc-render-context/src/load-handler.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,29 +5,26 @@

import * as Path from "path";
import * as requireAt from "require-at";
import * as optionalRequire from "optional-require";
import { makeOptionalRequire } from "optional-require";

const failLoadTokenModule = (msg: string, err: Error) => {
console.error(`error: @xarc/render-context failed to load token process module ${msg}`, err);
return () => ({
process: () => `\n@xarc/render-context: token process module ${msg} failed to load\n`
process: () => `\n@xarc/render-context: token process module ${msg} failed to load\n`,
});
};

const notFoundLoadTokenModule = (msg: string, err: Error) => {
console.error(
`error: @xarc/render-context can't find token process module ${msg}`,
err
);
console.error(`error: @xarc/render-context can't find token process module ${msg}`, err);
return () => ({
process: () => `\n@xarc/render-context: token process module ${msg} not found\n`
process: () => `\n@xarc/render-context: token process module ${msg} not found\n`,
});
};

export const loadTokenModuleHandler = (path: string, templateDir?: string, customCall?: string) => {
const tokenMod = optionalRequire(requireAt(Path.resolve(templateDir || "")))(path, {
const tokenMod: any = makeOptionalRequire(requireAt(Path.resolve(templateDir || "")))(path, {
fail: (e: Error) => failLoadTokenModule(path, e),
notFound: (e: Error) => notFoundLoadTokenModule(path, e)
notFound: (e: Error) => notFoundLoadTokenModule(path, e),
});
if (typeof tokenMod === "function") {
return tokenMod;
Expand Down

0 comments on commit 2581908

Please sign in to comment.