0.0.10 • Published 3 months ago

startup-run v0.0.10

Weekly downloads
-
License
MIT
Repository
github
Last release
3 months ago

NPM version Repository package.json version MIT License

startup-run

Run command-line scripts at startup with ease.

Supports Windows, macOS and Linux (Desktop).

Features

  • Run non-GUI scripts at startup, hidden.
  • Run as current user on Windows (running as service would cause problems for scripts with UI interactions).
  • Log to file.
  • Auto restart (respawn) on exit.

Installation

npm install startup-run

Usage

import {StartupRun} from 'startup-run';

const run = StartupRun.create('awesome-script');

await run.enable();

await run.disable();

await run.isEnabled(); // boolean

await run.start(); // start daemon.

await run.stop(); // stop daemon.

// Setup to enable/disable startup, this exits current process if either
// `enable` or `disable` is true.
await run.setup({
  enable: process.argv.includes('--startup'),
  disable: process.argv.includes('--disable-startup'),
});

StartupRun.daemonSpawned; // boolean, is current process spawned by daemon.

Default Options

const run = StartupRun.create('<name>', {
  command: process.execPath,
  args: process.argv.slice(1),
  cwd: process.cwd(),
  env: {},
  log: true,
  respawn: true,
});

Implementations

Windows

On Windows, it adds a startup item to registry at HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\Run, thus starting the script at login as current user.

Solutions like pm2 run scripts as service, which would cause problems for scripts with UI interactions.

Tested on:

  • Windows 11

macOS

On macOS, it adds a .plist file to ~/Library/LaunchAgents.

Tested on:

  • macOS Sonoma 14

Linux

On Linux, it adds a .desktop file to ~/.config/autostart.

Tested on:

  • Ubuntu 22.04 (Desktop)

Third Parties

node-auto-launch

Package startup-run is inspired by node-auto-launch but for different scenarios. While node-auto-launch focuses on GUI applications, startup-run focuses on scripts instead.

It refers some implementation details from node-auto-launch, but is overall refactored or rewritten to better serve its own design goals.

License

MIT License.

0.0.10

3 months ago

0.0.9

3 months ago

0.0.8

7 months ago

0.0.7

7 months ago

0.0.5

8 months ago

0.0.4

8 months ago

0.0.3

8 months ago

0.0.2

8 months ago

0.0.1

8 months ago

0.0.0

8 months ago