Coder Social home page Coder Social logo

Examples? about watchman HOT 7 CLOSED

facebook avatar facebook commented on May 4, 2024 8
Examples?

from watchman.

Comments (7)

michaelprescott avatar michaelprescott commented on May 4, 2024 27

Landed here looking for the same thing. Documentation is good, and a variety of usage examples would be very helpful.

from watchman.

aljungberg avatar aljungberg commented on May 4, 2024 16

Yep agree with the above. A couple of solid, common CLI examples at the top of the README would go a long way.

from watchman.

wez avatar wez commented on May 4, 2024 3

Take a look at https://algorithms.rdio.com/post/make/ for an example.

For your use case, I'd probably do something like this, which runs make whenever any file in the jsx folder is changed, or any .css file in the sass is changed (note: changed also includes created or deleted):

watchman -j <<-EOT
["trigger", "/path/to/root", {
  "name": "assets",
  "expression": ["anyof",
       ["match", "jsx/*", "wholename"],
       ["match", "sass/*.css", "wholename"]
  ],
  "command": ["make"]
}]
EOT

Watchman doesn't know anything about building anything; it knows when things change and how to trigger a command when that happens. This means that it is up to you to fill in the logic for building stuff.

Watchman is a little different from most other watching utilities because it is optimized for machines and not really for humans; the output of your triggered commands lands in a log file and not in your terminal.

from watchman.

janosh avatar janosh commented on May 4, 2024 1

Looks like the examples situation still hasn't improved. I'm trying to figure out how to access the names of files that triggered a command in said command. Seems simple enough.

from watchman.

williamcotton avatar williamcotton commented on May 4, 2024

Thank you very much for the examples. I was some how missing how these commands were issued to watchman. I'm guessing I could put that JSON in to a file and pass the filename to watchman as an argument?

Just this basic example has made the rest of the documentation in the README make complete sense! Thanks again :)

from watchman.

wez avatar wez commented on May 4, 2024

You can either type the command as I pasted it above, or put the json in a file named, say, trigger.json and then run watchman -j < trigger.json.

The example I pasted was slightly modified from one that was actually in the README. Is there a specific spot in the README where you started to feel lost/tuned out? We should probably juggle things around a bit to make the docs more accessible, and your feedback on this would help us do that.

from watchman.

williamcotton avatar williamcotton commented on May 4, 2024

Thanks again!

I think the main issue is with the "legacy" command line stuff that is mixed in with the newer, JSON commands. I haven't really made a connection on how the two are related.

If there were just 3-4 common use examples it would help out a lot. It would be nice if each example showed both the CLI version as well as the JSON version. Personally, I'd rather use the CLI version so I don't have to hardcode or fiddle around with absolute paths in a block of JSON.

I still haven't figured out how to translate your above example to CLI or to use relative paths in the JSON... I could write a script to generate the absolute path in the JSON, but I've shaved enough yaks for the day. 😄

And put something about watchman -j < trigger.json in there as well, that is pretty helpful! I know that is a shell command but when I'm using a new tool for the first time it can be hard to shift gears.

from watchman.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.