Can I watch files outside of current directory with `npm run watch`?

274 Views Asked by At

I work with two repo's; one with source code and one with E2E tests using CucumberJS:

  1. application-repo/
  2. application-e2e/

I would like to run npm run watch in the second repo and wait for changes to files in the first repo; because I want to have my CucumberJS tests run on changes to the source-code. The place I work dictate me not to have the e2e-tests in the same repo, as the source code.

Similar question, but with pm2 instead of npm-watch / watch: Watch files outside the current directory using pm2

1

There are 1 best solutions below

0
On

It was a lot easier than I thought, at least when using watch and not npm-watch, but probably both can be used the same way.

Here's my package.json of the second repo:

{
  "name": "application-e2e",
  "version": "1.0.0",
  "description": "",
  "main": "index.js",
  "scripts": {
    "watch":"watch 'echo hello' ../application-repo/", // First repo

  (...)

When running npm run watch in the second repo, changes made in the first repo will make it write hello in the terminal of the second repo.