Called on file(s) modifications that the Guard watches.
 @param [Array<String>] paths the changes files or paths
 @raise [:task_has_failed] when run_on_change has failed
494647
def run_on_changes(paths)
      paths += @failed_paths if @options[:keep_failed]
      paths = @inspector.clean(paths).uniq

      if passed = @runner.run(paths)
        remove_failed(paths)

        # run all the specs if the run before this one failed
        if @last_failed && @options[:all_after_pass]
          @last_failed = false
          run_all
        end
      else
        @last_failed = true
        add_failed(paths)

        throw :task_has_failed
      end
    end
1185019
public function watch($files)
    {
        $files = (array) $files;

        foreach ($files as $file) {
            $path = realpath($file);
            $this->_watched[$path] = $path;
        }
        $this->refreshWatched();
    }
822889
def run_and_collect_multiple_changes(monitor, times, directory, *flags, &block)
      watch_and_run(monitor, times, false, directory, *flags, &block)
    end
1043323
public function detectChanges()
    {
        if ($this->changedFiles === null || $this->changedPaths === null) {
            $this->loadDetectedDirectoriesAndFiles();
            $changesDetected = false;
            $this->changedPaths = $this->changedFiles = [];
            $this->changedFiles = $this->detectChangedFiles($this->monitoredFiles);

            foreach ($this->monitoredDirectories as $path => $filenamePattern) {
                $changesDetected = $this->detectChangesOnPath($path, $filenamePattern) ? true : $changesDetected;
            }

            if ($changesDetected) {
                $this->saveDetectedDirectoriesAndFiles();
            }
            $this->directoriesAndFiles = null;
        }

        $changedFileCount = count($this->changedFiles);
        $changedPathCount = count($this->changedPaths);

        if ($changedFileCount > 0) {
            $this->emitFilesHaveChanged($this->identifier, $this->changedFiles);
        }
        if ($changedPathCount > 0) {
            $this->emitDirectoriesHaveChanged($this->identifier, $this->changedPaths);
        }
        if ($changedFileCount > 0 || $changedPathCount) {
            $this->logger->info(sprintf('File Monitor "%s" detected %s changed files and %s changed directories.', $this->identifier, $changedFileCount, $changedPathCount), LogEnvironment::fromMethodName(__METHOD__));
        }
    }
1156124
private void moveTaskOutputs(TaskAttemptContext context,
                               FileSystem fs,
                               Path jobOutputDir,
                               Path taskOutput) 
  throws IOException {
    TaskAttemptID attemptId = context.getTaskAttemptID();
    context.progress();
    if (fs.isFile(taskOutput)) {
      Path finalOutputPath = getFinalPath(jobOutputDir, taskOutput, 
                                          workPath);
      if (!fs.rename(taskOutput, finalOutputPath)) {
        if (!fs.delete(finalOutputPath, true)) {
          throw new IOException("Failed to delete earlier output of task: " + 
                                 attemptId);
        }
        if (!fs.rename(taskOutput, finalOutputPath)) {
          throw new IOException("Failed to save output of task: " + 
        		  attemptId);
        }
      }
      LOG.debug("Moved " + taskOutput + " to " + finalOutputPath);
    } else if(fs.getFileStatus(taskOutput).isDir()) {
      FileStatus[] paths = fs.listStatus(taskOutput);
      Path finalOutputPath = getFinalPath(jobOutputDir, taskOutput, workPath);
      fs.mkdirs(finalOutputPath);
      if (paths != null) {
        for (FileStatus path : paths) {
          moveTaskOutputs(context, fs, jobOutputDir, path.getPath());
        }
      }
    }
  }
843414
def execute_tasks(tasks,template_path)
      
      if File.exists?(File.expand_path(File.join(template_path,'tasks.rb')))
        load File.expand_path(File.join(template_path,'tasks.rb'))
      end
       
      tasks.each{
        |task|
        
        puts 'Running Task: ' + task
        
        task = replace_tags(task);
        
        options = task.split(', ')
        action = options.slice!(0)
        
        if(Tasks.respond_to?(action))
          Tasks.send action, options.join(', ')
        else
          send action, options.join(', ')
        end
        
      }
                  
    end
342357
def on_any_path?(paths)
	      path_found = false
	      paths.each do |path|
	       	path_found = on_path?(path) ? true : path_found
	      end
	      return path_found
	    end
485969
private void monitorForChanges() {
        if (monitorRunning) {
            return;
        }

        final Path path;
        try {
            path = Paths.get(configPath);
        } catch (final Exception e) {
            LOGGER.warn("Cannot monitor configuration {}, disabling monitoring; {}", configPath, e.getMessage());
            return;
        }

        if (!path.toFile().exists()) {
            LOGGER.debug("Configuration {} does not exist, disabling monitoring", configPath);
            return;
        }
        final Path directoryPath = path.getParent();

        try {
            final WatchService watchService = FileSystems.getDefault().newWatchService();
            directoryPath.register(watchService, ENTRY_MODIFY);

            monitorThread = new Thread(new Runnable() {

                @Override
                public void run() {
                    try {
                        for (;;) {
                            final WatchKey key;
                            try {
                                key = watchService.take();
                            } catch (final InterruptedException e) {
                                LOGGER.debug("Interrupted the configuration monitor thread.");
                                break;
                            }

                            for (final WatchEvent<?> event : key.pollEvents()) {
                                final WatchEvent.Kind<?> kind = event.kind();
                                if (kind == OVERFLOW) {
                                    continue;
                                }

                                // If the configuration file triggered this event, reload it
                                final Path changed = (Path) event.context();
                                if (changed.equals(path.getFileName())) {
                                    LOGGER.info(
                                            "Configuration {} has been updated, reloading.",
                                            path);
                                    try {
                                        loadConfiguration();
                                    } catch (final IOException e) {
                                        LOGGER.error("Failed to reload configuration {}", configPath, e);
                                    }
                                }

                                // reset the key
                                final boolean valid = key.reset();
                                if (!valid) {
                                    LOGGER.debug("Monitor of {} is no longer valid", path);
                                    break;
                                }
                            }
                        }
                    } finally {
                        try {
                            watchService.close();
                        } catch (final IOException e) {
                            LOGGER.error("Failed to stop configuration monitor", e);
                        }
                    }
                    monitorRunning = false;
                }
            });
        } catch (final IOException e) {
            LOGGER.error("Failed to start configuration monitor", e);
        }

        monitorThread.start();
        monitorRunning = true;
    }
113802
def watch_file(path, func, *args, **kwargs):
    
    if not path:
        raise ValueError('Please specify a file to watch')
    print('Watching "{}" for changes'.format(path))
    last_modification_time = os.path.getmtime(path)
    try:
        while True:
            time.sleep(1)
            new_modification_time = os.path.getmtime(path)
            if new_modification_time == last_modification_time:
                continue
            func(*args, **kwargs)
            last_modification_time = new_modification_time
    except KeyboardInterrupt:
        pass
190766
def run_on_change(res)
      messages = []
      res.each do |file|
        file = File.join( options[:watchdir].to_s,file ) if options[:watchdir]

        if options[:syntax_check]
          parser_messages = `puppet parser validate #{file} --color=false`.split("\n")
          parser_messages.reject! { |s| s =~ /puppet help parser validate/ }
          parser_messages.map! { |s| s.gsub 'err: Could not parse for environment production:', '' }

          messages += prepend_filename(parser_messages, file)
        end

        @linter.file = file
        @linter.clear_messages
        @linter.run
        linter_msg = @linter.messages.reject { |s| !options[:show_warnings] && s =~ /WARNING/ }
        messages += prepend_filename(linter_msg, file)
      end
      if messages.empty?
        messages = ["Files are ok:"] + res
        image = :success
      else
        image = :failed
      end
      Notifier.notify( messages.join("\n"), :title => "Puppet lint", :image => image )
    end
994404
def _changes(path):
    
    res = [path[0]]
    res += [p - p_prev for p, p_prev in zip(path[1:], path)]
    return res
1183876
def ask_run_new_file(new_file_path, source_path, tmp)
      return if tmp && IRT.rails_server
      original_ask_run_new_file(new_file_path, source_path, tmp)
    end
1335877
def run_on_modifications(paths)
      change_scope, job_name = @change_assessor.determine_scope(paths)
      errors = case change_scope
               when :all
                 reload_deployment_manifest
                 render_all_job_templates
               when :all_templates_for_job
                 render_templates_for_job(
                   job_name, @job_repository.template_paths(job_name))
               when :single_template
                 render_templates_for_job(job_name, paths)
               end
      notify_errors(errors)
    end
1049768
function watchModules(paths) {

    paths || (paths = []);

    if (!Array.isArray(paths)) { paths = [paths]; }

    // for all directories / files in `config.watch` array
    paths.forEach(function(watchPath) {

      // watch modules for changes
      this.watch(watchPath, function(eventPath, stat) {

        // delete from the warm cache, the next require will be fresh
        var cached = require.cache[path.resolve(eventPath)];
        var children;

        if (!cached) return;

        cached.children.forEach(function(module) {
          delete require.cache[module.id]
        });
        delete require.cache[cached.parent.id];
        delete require.cache[path.resolve(eventPath)]

      });

    }.bind(this));
  }
948269
def run_on_removals(paths)
      return unless options[:delete]
      validate_at_least_one_target('delete')
      with_all_target_paths(paths) do |_, to_path|
        validate_to_file(to_path)
        UI.info("deleting #{to_path}") if options[:verbose]
        FileUtils.rm(to_path)
      end
    end
1211984
def check_files(files)
      files.each { |file| check_file(file) if file.is_a? String }
    end
796086
def run_on_removals(paths)
      Runner.remove(Inspector.clean(paths, :missing_ok => true), watchers, options)
    end