ailocalkit
v1.0.0
Published
Manages a local application process, starting it when needed and stopping it after inactivity
Maintainers
Readme
Spawn Apps
A utility for managing local application processes, starting them when needed and stopping them after inactivity.
Features
Start and stop applications with a single line of code
Automatically manage process lifecycle
Set custom timeouts for auto-shutdown
Register custom applications with OS-specific paths
TypeScript support with type definitions
Cross-platform support (macOS, Windows, Linux)
TypeScript Setup
This project is now written in TypeScript.
The build process generates JavaScript files and TypeScript declaration files (.d.ts)
in the dist directory.
To build the project:
Install dependencies:
npm installBuild the TypeScript code:
npm run buildThis will compile the TypeScript files to JavaScript in the
distdirectory.Run the example:
npm run start:example
Alternatively, you can run the build script which handles all of the above:
./build.shDevelopment
Run in watch mode to automatically recompile on changes:
npm run devClean the build directory:
npm run clean
Usage
After building, you can import the library from the dist directory:
import { startApp, stopApp } from "./dist/index.js";
// Or when installed as a package:
// import { startApp, stopApp } from "spawn-apps";
// Start an application with arguments (returns a Promise)
await startApp("Desktop Crawler", ["--headless", "--firecrawl-headless"]);
// Your application code here...
// Stop the application when done
stopApp("Desktop Crawler");API Reference
startApp(appName: string, args: string[] = [], timeout: number = DEFAULT_TIMEOUT): Promise<boolean>
Starts an app with the given arguments and sets an auto-shutdown timeout.
stopApp(appName: string, timeout: number = 0): boolean
Stops the app immediately or schedules a stop after the specified timeout.
registerApp(appName: string, options: AppOptions): void
Registers a new app with the registry, specifying bundle ID and OS-specific paths.
License
MIT
