jxa-runner

JXA Runner runs JavaScript and TypeScript code using the JXA runtime. It's intended to be used for testing JXA code rather than running JXA in production.

MIT License

Stars
1

JXA Runner

JXA Runner runs JavaScript and TypeScript code using the JXA runtime. It's intended to be used for testing JXA code rather than running JXA in production.

Installation

This package is available on npm as jxa-runner.

npm install jxa-runner

Usage

Basic Usage

import { run } from 'jxa-runner';

// returns "Hello, world!"
await run(() => 'Hello, world!');

// returns "Hello, John!"
await run((name: string) => `Hello, ${name}!`, {
  args: ['John'],
});

Importing Modules

import { run } from 'jxa-runner';
import z from 'zod';

// returns { name: "John", age: 37 }
const result = await run(
  () => {
    const PersonSchema = z.object({
      name: z.string(),
      age: z.number(),
    });

    return PersonSchema.parse({ name: 'John', age: 37 });
  },
  {
    imports: {
      zod: 'z',
    },
  },
);

Contributing

Pull requests are welcome. For major changes, please open an issue first to discuss what you would like to change.

Please make sure to update tests as appropriate.

License

JXA Runner is licensed under the MIT License.