Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

onchange

Package Overview
Dependencies
Maintainers
2
Versions
39
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

onchange

Use glob patterns to watch file sets and run a command when anything is added, changed or deleted.

  • 2.5.0
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
157K
decreased by-7%
Maintainers
2
Weekly downloads
 
Created

What is onchange?

The 'onchange' npm package is a simple tool that allows you to watch files and directories for changes and then execute commands in response to those changes. It is particularly useful for automating tasks in development workflows, such as running tests, building projects, or restarting servers when files are modified.

What are onchange's main functionalities?

Watch Files and Execute Commands

This feature allows you to watch JavaScript files in your project and run the 'npm test' command whenever any of these files change. The '**/*.js' pattern ensures that all JavaScript files in the project are monitored.

onchange '**/*.js' -- npm test

Watch Multiple Patterns

You can watch multiple file patterns simultaneously. In this example, both source and test JavaScript files are being watched, and the 'npm run build' command is executed whenever any of these files change.

onchange 'src/**/*.js' 'test/**/*.js' -- npm run build

Run Multiple Commands

This feature allows you to run multiple commands in sequence when a change is detected. Here, it first echoes 'Files changed' and then runs the 'npm run lint' command.

onchange 'src/**/*.js' -- echo 'Files changed' && npm run lint

Ignore Specific Files or Directories

You can exclude specific files or directories from being watched. In this example, all JavaScript files are watched except those in the 'node_modules' directory.

onchange '**/*.js' --exclude 'node_modules/**' -- npm test

Other packages similar to onchange

Keywords

FAQs

Package last updated on 07 Jun 2016

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc