Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Using phatjs wasm in async runtime #36

Merged
merged 4 commits into from
Feb 28, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -9,3 +9,4 @@
/tmp
node_modules
oclif.manifest.json
.npmrc
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,7 @@
}
},
"scripts": {
"build": "shx rm -rf dist && tsc -b",
"build": "shx rm -rf dist && tsc -b && shx cp src/lib/phatjs/phatjs_bg.*.wasm dist/lib/phatjs/",
"lint": "tsc --noEmit",
"test": "mocha --forbid-only \"test/**/*.test.ts\""
},
Expand Down
6 changes: 2 additions & 4 deletions src/commands/run.ts
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ export default class Run extends Command {
}),
}

public async run(): Promise<{ output: string }> {
public async run() {
const {
flags: { scriptArgs = [], experimentalAsync },
args: { script },
Expand All @@ -39,8 +39,6 @@ export default class Run extends Command {
isAsync: experimentalAsync,
})
this.log(JSON.stringify({ output }))
return {
output,
}
process.exit(0)
}
}
36 changes: 36 additions & 0 deletions src/lib/phatjs/phatjs.d.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
/* tslint:disable */
/* eslint-disable */
/**
*/
export function start(): void;
/**
* Get the version of the runtime.
* @returns {Promise<string>}
*/
export function version(): Promise<string>;
/**
* Run a script.
*
* # Arguments
* - `args` - a list of arguments to pass to the runtime, including the script name and arguments.
*
* # Example
*
* ```js
* const result = await run(["phatjs", "-c", "console.log(scriptArgs)", "--", "Hello, world!"]);
* console.log(result);
* ```
* @param {(string)[]} args
* @returns {Promise<any>}
*/
export function run(args: (string)[]): Promise<any>;
/**
* Set a hook for the runtime.
*
* # Available hooks
* - `fetch` - a function that takes a `Request` object and returns a `Response` object.
* @param {string} hook_name
* @param {any} hook_value
*/
export function setHook(hook_name: string, hook_value: any): void;
export function init(): void;
Loading
Loading