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

npm-watch

Package Overview
Dependencies
Maintainers
4
Versions
27
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

npm-watch

run scripts from package.json when files change

  • 0.6.0
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
243K
increased by24.13%
Maintainers
4
Weekly downloads
 
Created

What is npm-watch?

npm-watch is a utility that allows you to run scripts in response to file changes. It is particularly useful for automating tasks such as building, testing, or linting your code whenever you make changes.

What are npm-watch's main functionalities?

Watch and Run Scripts

This feature allows you to watch specific files or directories and run a script when changes are detected. In this example, the 'build' script will run whenever a JavaScript file in the 'src' directory changes.

{
  "scripts": {
    "build": "webpack",
    "watch": "npm-watch"
  },
  "watch": {
    "build": {
      "patterns": ["src/**/*.js"],
      "extensions": "js"
    }
  }
}

Custom Watch Patterns

You can specify custom patterns to watch multiple directories or file types. In this example, the 'test' script will run whenever a JavaScript file in either the 'test' or 'src' directories changes.

{
  "scripts": {
    "test": "mocha",
    "watch": "npm-watch"
  },
  "watch": {
    "test": {
      "patterns": ["test/**/*.js", "src/**/*.js"],
      "extensions": "js"
    }
  }
}

Run Multiple Scripts

You can configure npm-watch to run multiple scripts based on different file changes. In this example, both 'lint' and 'build' scripts are set to run when JavaScript files in the 'src' directory change.

{
  "scripts": {
    "lint": "eslint .",
    "build": "webpack",
    "watch": "npm-watch"
  },
  "watch": {
    "lint": {
      "patterns": ["src/**/*.js"],
      "extensions": "js"
    },
    "build": {
      "patterns": ["src/**/*.js"],
      "extensions": "js"
    }
  }
}

Other packages similar to npm-watch

Keywords

FAQs

Package last updated on 22 Jan 2019

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