Code Monkey home page Code Monkey logo

Comments (13)

semaperepelitsa avatar semaperepelitsa commented on June 12, 2024 2

If anyone is interested to just run a command without passing changed files, you need to replace this:

$ fswatch . | xargs -n1 echo updated
updated /path/to/file
updated /path/to/file
updated /path/to/file

With this:

$ fswatch -o . | xargs -n1 -I "{}" echo updated
updated
updated
updated

Substitute "echo updated" with your own command.

from fswatch.

ricardobeat avatar ricardobeat commented on June 12, 2024 1

I was also surprised today when my work setup suddenly stopped working :(

Are we expected to run a while true; do fswatch --one-event && mycmd; done loop now? Feels like going backwards.

from fswatch.

emcrisostomo avatar emcrisostomo commented on June 12, 2024 1

Hi @bwiklund, @ricardobeat, @jenmontes,

I've just released v. 1.3.3 where:

  • The -o option instructs fswatch to only print one line with the number of the change events received in the last "batch". This way, you can use this event to trigger the execution of another program, as discussed in this issue and in Issue 20.
  • The fswatch-run script has been added to ease the transition from v. 0.x to 1.x. This scripts accepts the older fswatch path command syntax and invokes fswatch -o piping its output to xargs for you. Being a one-liner, I still strongly suggest adapting your script to the new behaviour.

from fswatch.

bwiklund avatar bwiklund commented on June 12, 2024

FYI this is on version 1.3.2 via brew

from fswatch.

cuibonobo avatar cuibonobo commented on June 12, 2024

I'm also having this issue. I'm on OS X 10.9.2 and fswatch 1.3.2.

from fswatch.

emcrisostomo avatar emcrisostomo commented on June 12, 2024

Hi @bwiklund, @ricardobeat, @jenmontes,

fswatch has been merged with another utility (fsw) and its behaviour has changed. The change is not backward-compatible and the major version number has been increased to give users a warning.

The new behaviour is printing change events to standard output so that users can pipe any process to fswatch and process them as they like. This behaviour is more consistent with common UNIX practices and gives the user more flexibility.

The quickest way to update the scripts that rely on fswatch is piping its output and execute the command you want to run:

fswatch -0 . | xargs -0 -n1 program-to-run

Please, have a look at Issue 20, where a discussion about this functional change took place.

Cheers,
-- Enrico M. Crisostomo

from fswatch.

ricardobeat avatar ricardobeat commented on June 12, 2024

Hi @emcrisostomo, thanks for answering. I blame homebrew that doesn't allow you to easily specify versions :(

I understand the appeal of unix tools, and use them a lot to my advantage, but the reason for choosing fswatch was it's simplicity for my use case (also involving rsync); adding 5-10 lines dealing with file events to an already complex ever-growing shell script is not something I'd like to do.

I'll be using spy in the meantime. Maybe a --run | --command option can be added that also emits a single event per batch?

from fswatch.

emcrisostomo avatar emcrisostomo commented on June 12, 2024

Hi @ricardobeat,

You and your suggestions are welcome.

May I suggest you use xargs, as suggested above? I guess that wouldn't add much complexity to your scripts:

fswatch -0 . | xargs -0 -n1 program-to-run

It's a bit more verbose, but way more powerful (one of the reasons I wanted fswatch events to be pipeable was filtering).

On the other hand, if the event detail is not important (as I infer from your suggestion about --run), then I guess these are all votes for that feature, which is now the subject of Issue 20 and I'm going to implement the feature of emitting one single event per batch.

I'll leave this open for reference.

Thanks,
Enrico M. Crisostomo

from fswatch.

bwiklund avatar bwiklund commented on June 12, 2024

Awesome, thanks. Is there anything to be done to get the latest version on brew? I don't know how that process works.

from fswatch.

ekeyser avatar ekeyser commented on June 12, 2024

I was curious about this as well and I think the homebrew formula needs to be updated because it's hardcoded to pull release 1.3.2.

ref
Homebrew/legacy-homebrew@f8d9abb#diff-4b2a65915d48a425136a0b28970ccb47

from fswatch.

emcrisostomo avatar emcrisostomo commented on June 12, 2024

Hi @bwiklund, @ekeyser

Neither do I, to say the truth. I Just forked Homebrew/homebrew, updated the source tarball URL and checksum in the fswatch formula and sent a pull request. Not sure whether this is the proper way to notify them, though.

from fswatch.

benesch avatar benesch commented on June 12, 2024

@emcrisostomo that's exactly the recommended process.

from fswatch.

emcrisostomo avatar emcrisostomo commented on June 12, 2024

Thank you very much @benesch.

from fswatch.

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.