Created
September 12, 2012 15:53
-
-
Save melo/3707617 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env perl | |
# | |
# Filesystem changes trigger | |
use v5.14; | |
use FindBin; | |
use lib "$FindBin::Bin/../lib"; | |
use E1::Setup::Perl; | |
use Filesys::Notify::Simple; | |
$|++; | |
my ($dir, @cmd) = @ARGV; | |
die("FATAL: '$dir' is not a valid directory\n") unless -d $dir; | |
die("FATAL: need a command to run\n") unless @cmd; | |
my $watcher = Filesys::Notify::Simple->new([$dir]); | |
say "\n** Start waiting for changes to '$dir'"; | |
$watcher->wait( | |
sub { | |
say "\n** Filesystem change detection:"; | |
say " $_->{path}" for @_; | |
say "\n** Executing command:"; | |
say " @cmd"; | |
system(@cmd); | |
my $path = "$FindBin::Bin/../.release"; | |
if (-f $path) { | |
my $now = time; | |
utime($now, $now, $path); | |
say "\n** Updated $path timestamp\n"; | |
} | |
} | |
) while 1; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment