Skip to main content
Home

Built and signed on GitHub Actions

latest

Start a process and restart it any time a source file in the repository changes.

This package works with Node.js, Deno, BunIt is unknown whether this package works with Cloudflare Workers, Browsers
It is unknown whether this package works with Cloudflare Workers
This package works with Node.js
This package works with Deno
This package works with Bun
It is unknown whether this package works with Browsers
JSR Score
100%
Published
3 months ago (0.1.2)

Watch

Watch is a very simple tool that does one thing: run a command, and every time source files change in a directory, shutdown the current invocation gracefully and restart it.

deno -A jsr:@effectionx/watch npm start

Graceful Shutdown

Watch will send SIGINT and SIGTERM to your command, and then wait until its stdout stream is closed, indicating that it has no further output. It will not attempt to start your command again until that has happened. This is important, because your process might be holding onto any number of resources that have to be safely released before exiting.

Git aware

If you are running this command inside a git repository, it will only perform restarts on files that are under source control, or could be candidates for source control (not ignored).

Use it as an Effection library

Most of the time, you will use this an executable. However, if you want to create your own watch from within a library, you can But if you want to write your own

import { each, main } from "effection";
import { watch } from "@effectionx/watch";

await main(function* () {
  const changes = watch({
    path: "./src",
    cmd: "npm test",
  });

  for (let start of yield* each(changes)) {
    console.log(start);
    yield* each.next();
  }
});
Built and signed on
GitHub Actions

New Ticket: Report package

Please provide a reason for reporting this package. We will review your report and take appropriate action.

Please review the JSR usage policy before submitting a report.

Add Package

deno add jsr:@effectionx/watch

Import symbol

import * as watch from "@effectionx/watch";
or

Import directly with a jsr specifier

import * as watch from "jsr:@effectionx/watch";

Add Package

pnpm i jsr:@effectionx/watch
or (using pnpm 10.8 or older)
pnpm dlx jsr add @effectionx/watch

Import symbol

import * as watch from "@effectionx/watch";

Add Package

yarn add jsr:@effectionx/watch
or (using Yarn 4.8 or older)
yarn dlx jsr add @effectionx/watch

Import symbol

import * as watch from "@effectionx/watch";

Add Package

vlt install jsr:@effectionx/watch

Import symbol

import * as watch from "@effectionx/watch";

Add Package

npx jsr add @effectionx/watch

Import symbol

import * as watch from "@effectionx/watch";

Add Package

bunx jsr add @effectionx/watch

Import symbol

import * as watch from "@effectionx/watch";