File tree Expand file tree Collapse file tree 3 files changed +20
-13
lines changed
Expand file tree Collapse file tree 3 files changed +20
-13
lines changed Original file line number Diff line number Diff line change 1- import * as fs from "javy/fs" ;
2-
31// This package name will be aliased to the file provided by the user.
42import * as userFunction from "user-function" ;
3+ import run from "./run" ;
54
6- export type ShopifyFunction < Input extends { } , Output extends { } > = (
7- input : Input
8- ) => Output ;
9-
10- const input_data = fs . readFileSync ( fs . STDIO . Stdin ) ;
11- const input_str = new TextDecoder ( "utf-8" ) . decode ( input_data ) ;
12- const input_obj = JSON . parse ( input_str ) ;
13- const output_obj = userFunction ?. default ( input_obj ) ;
14- const output_str = JSON . stringify ( output_obj ) ;
15- const output_data = new TextEncoder ( ) . encode ( output_str ) ;
16- fs . writeFileSync ( fs . STDIO . Stdout , output_data ) ;
5+ run ( userFunction ?. default )
Original file line number Diff line number Diff line change 1616 "@graphql-codegen/typescript-operations" : " ^2.5.5" ,
1717 "graphql" : " ^16.6.0" ,
1818 "typescript" : " ^4.8.4"
19+ },
20+ "peerDependencies" : {
21+ "javy" : " ^0.1.0"
1922 }
2023}
Original file line number Diff line number Diff line change 1+ import * as fs from "javy/fs" ;
2+
3+ export type ShopifyFunction < Input extends { } , Output extends { } > = (
4+ input : Input
5+ ) => Output ;
6+
7+ export default function < I extends { } , O extends { } > ( userfunction : ShopifyFunction < I , O > ) {
8+ const input_data = fs . readFileSync ( fs . STDIO . Stdin ) ;
9+ const input_str = new TextDecoder ( "utf-8" ) . decode ( input_data ) ;
10+ const input_obj = JSON . parse ( input_str ) ;
11+ const output_obj = userfunction ( input_obj ) ;
12+ const output_str = JSON . stringify ( output_obj ) ;
13+ const output_data = new TextEncoder ( ) . encode ( output_str ) ;
14+ fs . writeFileSync ( fs . STDIO . Stdout , output_data ) ;
15+ }
You can’t perform that action at this time.
0 commit comments