Creates a hash of changed files keyed by their target nested directory,
 which is based on either the original source directory or the :output
 option, plus the regex match group in a watcher like:

    %r{^app/stylesheets/(.+\.less)$}
185804
def nested_directory_map(paths)
      directories = {}

      options[:patterns].product(paths).each do |pattern, path|
        next unless (matches = path.match(pattern))

        target = options[:output] || File.dirname(path)
        if (subpath = matches[1])
          target = File.join(target, File.dirname(subpath)).gsub(/\/\.$/, '')
        end

        (directories[target] ||= []) << path
      end

      directories
    end
754391
function globMatch(match, file) {
    var directiveType = match[1];
    var globPattern = match[2]; // relative file

    // require all files under a directory
    if (directiveType.indexOf('_tree') !== -1) {
      globPattern = globPattern.concat('/**/*');
      directiveType = directiveType.replace('_tree', '');
    }

    // require only first level files in a directory
    if (directiveType.indexOf('_directory') !== -1) {
      globPattern = globPattern.concat('/*');
      directiveType = directiveType.replace('_directory', '');
    }

    // Only require and include directives are allowed
    if (directiveType !== 'require' && directiveType !== 'include') {
      return [];
    }

    // Add file extension to glob pattern if not already set
    var jsExt = '.js';
    if (globPattern.substr(globPattern.length-jsExt.length).indexOf(jsExt) !== 0) {
      globPattern += jsExt;
    } 

    // Append the current dir to include so we can match the glob against the file list
    var relativeDir = getRelativeDir(file);
    globPattern = relativeDir+globPattern;

    var possibleIncludes = [];
    _.each(_.keys(allFiles), function(fileName) {
      // Only process files in the current directory. ../ will not work.
      if (fileName.indexOf(relativeDir) !== 0) {
        return;
      }

      possibleIncludes.push(fileName);
    });
    
    return minimatch.match(possibleIncludes, globPattern);
  }
615489
def path_to(hash = nil)
      @base_dir ||= File.join(Jekyll::Cache.cache_dir, @name)
      return @base_dir if hash.nil?

      File.join(@base_dir, hash[0..1], hash[2..-1]).freeze
    end
145974
function(cfg, callback) {
  var paths = cfg.input_files || cfg.input_file || cfg.input_dir;
  if (!Array.isArray(paths)) {
    paths = [paths];
  }
  
  watchr.watch({
    paths: paths,
    listener: function(eventName,filePath,fileCurrentStat,filePreviousStat){
      console.log(formatLog('File changed:', filePath));
      
      var singleFileCfg,
          outputDir,
          logTaskError = function(msg) {
            console.log('\n'+msg.red);
          };

      // Detect what build configuration the file belongs to
      if (config.scripts.indexOf(cfg) !== -1) {
        // rebuild scripts
        buildScripts(cfg, function(err){
          if (err) {
            logTaskError('Scripts not saved!');
          }
        });
      } else if (config.styles.indexOf(cfg) !== -1) {
        // rebuild styles
        buildStyles(cfg, function(err){
          if (err) {
            logTaskError('Styles not saved!');
          }
        });
      } else if (config.copy_files.indexOf(cfg) !== -1) {
        // copy files
        singleFileCfg = {input_files: [filePath], output_dir: cfg.output_dir};
        copyFiles(singleFileCfg, function(err){
          if (err) {
            logTaskError('File not copied!');
          }
        });
      } else if (config.copy_file.indexOf(cfg) !== -1) {
        // copy/rename single file
        singleFileCfg = {input_file: filePath, output_file: cfg.output_file};
        copyFile(singleFileCfg, function(err){
          if (err) {
            logTaskError('File not copied!');
          }
        });
      } else if (config.copy_dir.indexOf(cfg) !== -1) {
        // copy single directory
        outputDir = path.dirname(filePath).replace(cfg.input_dir, cfg.output_dir);
        singleFileCfg = {input_files: [filePath], output_dir: outputDir};
        copyFiles(singleFileCfg, function(err){
          if (err) {
            logTaskError('Directory not copied!');
          }
        });
      }
    },
    next: function(err,watcher){
      if (err) {
        callback(err);
      } else {
        callback();
      }
    }
  });
}
275316
def calc_dirs_with_files(sources)
      filemap = {}
      sources.keys.sort.reverse.each do |o|
        d = File.dirname(o)
        if filemap.include?(d)
          filemap[d] << o
        else
          filemap[d] = [o]
        end
      end
      return filemap
    end
81975
def target_dir( f = nil )
      if File.exists?( config_file_path )
        form_file_name( target_dir_from_config, f )
      else
        form_file_name( File.join( ::Rails.root.to_s, 'public/docs' ), f )
      end
    end
810166
function specToWatcherObj (watcherInstance, spec, options) {
  const dest = options.dest
  return new Promise((resolve, reject) => {
    const watcher = chokidar.watch(spec.files, {cwd: options.dir})
      .on('ready', () => {
        resolve({
          watcher: watcher,
          spec: spec
        })
      })
      .on('error', (err) => reject(err))
      .on('add', (path) => watcherInstance.emit('add', fileOptions.createFileUsingSpec(path, spec, dest)))
      .on('change', (path) => watcherInstance.emit('change', fileOptions.createFileUsingSpec(path, spec, dest)))
      .on('unlink', (path) => watcherInstance.emit('remove', fileOptions.createFileUsingSpec(path, spec, dest)))
  })
}
550478
def hash_dir(path):
    """"""
    dir_hash = {}

    for root, dirs, files in os.walk(path, topdown=False):
        f_hash = ((f, hash_file(join(root, f))) for f in files)
        d_hash = ((d, dir_hash[join(root, d)]) for d in dirs)
        # split+join normalizes paths on Windows (note the imports)
        dir_hash[join(*split(root))] = _mktree(f_hash, d_hash)

    return dir_hash[path]
296129
def process_result
      require 'sass'

      if !@options[:update] && !@options[:watch] &&
          @args.first && colon_path?(@args.first)
        if @args.size == 1
          @args = split_colon_path(@args.first)
        else
          @fake_update = true
          @options[:update] = true
        end
      end
      load_compass if @options[:compass]
      return interactive if @options[:interactive]
      return watch_or_update if @options[:watch] || @options[:update]
      super

      if @options[:sourcemap] != :none && @options[:output_filename]
        @options[:sourcemap_filename] = Sass::Util.sourcemap_name(@options[:output_filename])
      end

      @options[:for_engine][:filename] = @options[:filename]
      @options[:for_engine][:css_filename] = @options[:output] if @options[:output].is_a?(String)
      @options[:for_engine][:sourcemap_filename] = @options[:sourcemap_filename]
      @options[:for_engine][:sourcemap] = @options[:sourcemap]

      run
    end
806146
function(sourceDir, newDirLocation, opts) {

        if (!opts || !opts.preserve) {
            try {
                if(fs.statSync(newDirLocation).isDirectory()) {
                    exports.rmdirSyncRecursive(newDirLocation);
                }
            }
            catch(e) { }
        }

        /*  Create the directory where all our junk is moving to; read the mode of the source directory and mirror it */
        var checkDir = fs.statSync(sourceDir);
        try {
            fs.mkdirSync(newDirLocation, checkDir.mode);
        }
        catch (e) {
            //if the directory already exists, that's okay
            if (e.code !== 'EEXIST') {
                throw e;
            }
        }

        var files = fs.readdirSync(sourceDir);

        for(var i = 0; i < files.length; i++) {
            var currFile = fs.lstatSync(sourceDir + "/" + files[i]);

            if(currFile.isDirectory()) {
                /*  recursion this thing right on back. */
                copyDirectoryRecursiveSync(sourceDir + "/" + files[i], newDirLocation + "/" + files[i], opts);
            }
            else if(currFile.isSymbolicLink()) {
                var symlinkFull = fs.readlinkSync(sourceDir + "/" + files[i]);
                fs.symlinkSync(symlinkFull, newDirLocation + "/" + files[i]);
            }
            else {
                /*  At this point, we've hit a file actually worth copying... so copy it on over. */
                var contents = fs.readFileSync(sourceDir + "/" + files[i]);
                fs.writeFileSync(newDirLocation + "/" + files[i], contents);
            }
        }
    }
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
986690
def format_diff
      gemfile.changes.map do |gem, details|
        ERB.new(template, nil, '<>').result(binding)
      end
    end
461377
def update_hash(src_file):
    
    hash_file = local.path(src_file) + ".hash"
    new_hash = 0
    with open(hash_file, 'w') as h_file:
        new_hash = get_hash_of_dirs(src_file)
        h_file.write(str(new_hash))
    return new_hash
839626
def find_source(gem, source)
      case source
      when Bundler::Source::Rubygems
        GemUpdater::RubyGemsFetcher.new(gem, source).source_uri
      when Bundler::Source::Git
        source.uri.gsub(/^git/, 'http').chomp('.git')
      end
    end
683200
def _watch_folder(folder, destination, compiler_args):
    """"""
    for dirpath, dirnames, filenames in os.walk(folder):
        for filename in filenames:
            # Ignore filenames starting with ".#" for Emacs compatibility
            if watched_extension(filename) and not filename.startswith('.#'):
                fullpath = os.path.join(dirpath, filename)
                subfolder = os.path.relpath(dirpath, folder)
                mtime = os.stat(fullpath).st_mtime
                
                # Create subfolders in target directory if they don't exist
                compiled_folder = os.path.join(destination, subfolder)
                if not os.path.exists(compiled_folder):
                    os.makedirs(compiled_folder)
                
                compiled_path = _compiled_path(compiled_folder, filename)
                if (not fullpath in compiled or
                    compiled[fullpath] < mtime or
                    not os.path.isfile(compiled_path)):
                    compile_file(fullpath, compiled_path, compiler_args)
                    compiled[fullpath] = mtime
989144
def find_lints(ruby, source_map)
      rubocop = ::RuboCop::CLI.new

      filename =
        if document.file
          "#{document.file}.rb"
        else
          'ruby_script.rb'
        end

      with_ruby_from_stdin(ruby) do
        extract_lints_from_offenses(lint_file(rubocop, filename), source_map)
      end
    end
734221
function (files) {
    if (!_.isArray(files)) files = [files];
    return _.chain(files).map(fss.target).map(function (f) {
        if (!fss.directoryExists(f)) return f;
        return fss.allTargetFilePaths(f);
    }).flatten().uniq().reject(fss.isDotFile).map(pathSuffix).value();
}