Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8772415
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 13, 20262026-06-13T18:01:33+00:00 2026-06-13T18:01:33+00:00

I have guard (the ruby gem) setup and working it seems on my Mac

  • 0

I have guard (the ruby gem) setup and working it seems on my Mac and setting up a guard from guard-coffee and guard-shell seem to work fine. Here is the related section of my Guardfile below

guard 'coffeescript', :input => 'src/javascripts', :output => 'public/javascripts'
guard 'shell' do
    watch( %r{^public/.+\.(js|css)$} ) do |m|
        puts m.inspect
        if m[1] == 'js'
            puts 'a js is new!'
        else
            puts 'a css is new!'
        end
        puts %x{ echo #{File.mtime(m[0])} }
    end
end

Which seems to output ‘a js is new’ twice if I edit a coffeescript file. With debug on it seems to run after

13:39:23 - DEBUG - Hook :run_on_changes_begin executed for Guard::CoffeeScript
13:39:23 - INFO - Compile src/javascripts/blah.coffee
13:39:23 - INFO - 01:39:23 PM Successfully generated public/javascripts/blah.js
["public/javascripts/blah.js", "js"]
a js is new!

and

13:39:23 - DEBUG - Hook :run_on_changes_end executed for Guard::CoffeeScript
["public/javascripts/blah.js", "js"]
a js is new!

It does seem to only fire once if I edit the blah.js file directly. I was a little confused by how hooks work, can I key into a hook from another guard? Should I just run this code in a callback in the coffeescript guard? I was trying to use groups and only do the shell part if I was in a group and didn’t want to have to repeat the coffee guard in the case where I would use a callback instead.

Any thoughts on how I can stop triggering the shell guard twice when the coffe one fires?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-13T18:01:34+00:00Added an answer on June 13, 2026 at 6:01 pm

    Prior to Guard 1.0.0, new files created and updated from a Guard plugin did not trigger a subsequent file change for other plugins. This was a problem for example with the CoffeeScript and LiveReload plugins: When a JavaScript file has been updated, then LiveReload did not reload the file. As a workaround I added some manual file trigger code. With the Listen gem this limitation has been removed, thus the CoffeeScript plugin triggers file changes twice.

    I removed it on my master branch. Can you please give it a try before I release a new gem? You can do this easily by using my master branch by adding:


    gem 'guard-coffeescript', :github => 'netzpirat/guard-coffeescript', :branch => 'master'

    to your Gemfile. I’ll release a new gem asap when it works fine.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have the guard-rspec gem installed in my gemfile: group :development do gem guard-rspec
So I have been trying to get guard clauses to work with Caliburn.Micro and
Setup: Hi, I have Rails 3.2, Guard, RSpec and FactoryGirl. Pretty common. The Problem:
Running rails 3.2.3 with guard/spork/rspec/factory_girl and have the following in my spec helper: Spork.prefork
Ok, I have just run into something that is really catching me off-guard. I
I have: $ ruby -v ruby 1.9.2p290 (2011-07-09 revision 32553) [i686-linux] $ middleman version
Hi I'm working on a rails project with rspec, capybara, guard, spork with rails
I'm thinking I have angered the Header Guard gods, but I don't see where.
In my notes I have something like If (Guard & !Round & !Sticky) If
I had Compass 0.12 (a ruby gem) installed on Ubuntu Oneiric with no problems

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.