diff --git a/index.ts b/index.ts
index 8dc849b..523d317 100644
--- a/index.ts
+++ b/index.ts
@@ -1,16 +1,5 @@
-import * as fs from "javy/fs";
-
// This package name will be aliased to the file provided by the user.
import * as userFunction from "user-function";
+import run from "./run";
-export type ShopifyFunction = (
- input: Input
-) => Output;
-
-const input_data = fs.readFileSync(fs.STDIO.Stdin);
-const input_str = new TextDecoder("utf-8").decode(input_data);
-const input_obj = JSON.parse(input_str);
-const output_obj = userFunction?.default(input_obj);
-const output_str = JSON.stringify(output_obj);
-const output_data = new TextEncoder().encode(output_str);
-fs.writeFileSync(fs.STDIO.Stdout, output_data);
+run(userFunction?.default)
diff --git a/package.json b/package.json
index 98948d3..5720e01 100644
--- a/package.json
+++ b/package.json
@@ -16,5 +16,8 @@
"@graphql-codegen/typescript-operations": "^2.5.5",
"graphql": "^16.6.0",
"typescript": "^4.8.4"
+ },
+ "peerDependencies": {
+ "javy": "^0.1.0"
}
}
diff --git a/run.ts b/run.ts
new file mode 100644
index 0000000..5ebf344
--- /dev/null
+++ b/run.ts
@@ -0,0 +1,15 @@
+import * as fs from "javy/fs";
+
+export type ShopifyFunction = (
+ input: Input
+) => Output;
+
+export default function (userfunction: ShopifyFunction) {
+ const input_data = fs.readFileSync(fs.STDIO.Stdin);
+ const input_str = new TextDecoder("utf-8").decode(input_data);
+ const input_obj = JSON.parse(input_str);
+ const output_obj = userfunction(input_obj);
+ const output_str = JSON.stringify(output_obj);
+ const output_data = new TextEncoder().encode(output_str);
+ fs.writeFileSync(fs.STDIO.Stdout, output_data);
+}