Files
plainleaf/cmd/plug_run.ts
T
Zef HemelandGitHub a2dbf7b3db PlugOS refactor and other tweaks (#631)
* Prep for in-process plug loading (e.g. for CF workers, Deno Deploy)
* Prototype of fixed in-process loading plugs
* Fix: buttons not to scroll with content
* Better positioning of modal especially on mobile
* Move query caching outside query
* Fix annoying mouse behavior when filter box appears
* Page navigator search tweaks
2024-01-15 16:43:12 +01:00

41 lines
895 B
TypeScript

import { runPlug } from "../cli/plug_run.ts";
import { path } from "../common/deps.ts";
import assets from "../dist/plug_asset_bundle.json" with {
type: "json",
};
import { AssetBundle } from "../plugos/asset_bundle/bundle.ts";
export async function plugRunCommand(
{
hostname,
port,
}: {
hostname?: string;
port?: number;
},
spacePath: string,
functionName: string | undefined,
...args: string[]
) {
spacePath = path.resolve(spacePath);
console.log("Space path", spacePath);
console.log("Function to run:", functionName, "with arguments", args);
try {
const result = await runPlug(
spacePath,
functionName,
args,
new AssetBundle(assets),
port,
hostname,
);
if (result) {
console.log("Output", result);
}
Deno.exit(0);
} catch (e: any) {
console.error(e.message);
Deno.exit(1);
}
}