Recursively look up specified `layout` in front-matter and combine
contents with previous results on `temp` via `injectContent` method

@param {Object} tfiles
@param {String} tfile
@param {Object} resolved
@param {String} temp
@return {String}
432356
function resolveTemplate (tfiles, tfile, resolved, temp = '') {
    
    // If parent layout was called by a page directly (vs. through a child layout)
    // inject already resolved content with child `temp`
    if (resolved[tfile]) {
      return injectContent(resolved[tfile], temp);
    }
    
    // Process layout as prescribed
    else if (tfiles[tfile]) {
      
      // Lookup layout in tfiles tree
      let tdata = tfiles[tfile];
      
      // Combine parent-child on `temp` via `injectContent`
      temp = injectContent(tdata.contents.toString(), temp);
      
      // If this layout has a parent `layout` in front-matter, "lather, rinse, repeat"
      return tdata.layout ? resolveTemplate(tfiles, tdata.layout, resolved, temp) : temp;
    }
    else {
      return temp;
    }
  }
375598
def tempfile_path(content)
      tempfile = Tempfile.new('tty-editor')
      tempfile << content
      tempfile.flush
      unless tempfile.nil?
        tempfile.close
      end
      tempfile.path
    end
52809
function (srcFiles, destPath) {
    // Iterate over all specified file groups.
    srcFiles.map(grunt.file.read).forEach(function (fileContent, i) {
        var abspath = srcFiles[i];
        var results = fileContent.match(applyminGlobal.beginminPattern_global);
        if (results) {
            var beginminInfo = {};
            for (var index in results) {
                var result = results[index].match(applyminGlobal.beginminPattern);
                var beginEndMinBlock = result[0];
                var targetUrlPath = result[1];
                var staticBlock = result[2];  // static block, maybe css/js
                var targetFilePath = targetUrlPath.match(new RegExp(destPath + '/' + '\\S+\\.(css|js)', 'i'));
                if (!targetFilePath) {
                    grunt.warn('In the file: ' + abspath + ', the target filename in ' + targetUrlPath + ' should start with ' + destPath + '/' + ' and end with .css or .js');
                }
                targetFilePath = targetFilePath[0];
                _handleStaticBlock(abspath, targetFilePath, staticBlock);
                if (targetFilePath in beginminInfo) {
                    grunt.warn('In the file: ' + abspath + ', the target filename ' + targetFilePath + ' should not be duplicated.');
                }
                beginminInfo[targetFilePath] = {targetUrlPath:targetUrlPath, beginEndMinBlock:beginEndMinBlock};
            }
            // Store results for the applymin later.
            applyminGlobal.beginminInfos[abspath] = beginminInfo;
        }
    });
  }
1237702
def tmpfile (dir=None, prefix="temp", suffix=None):
    """"""
    return tempfile.mkstemp(suffix=suffix, prefix=prefix, dir=dir)[1]
361436
def resolve_deps(base_dir, file_index):
  
  def flatten(tree, index = {}):
    for include in tree.get('include', []):
      fname = base_dir + "/" + include
      assert os.path.exists(fname), "File %s does not exist." % fname
      if fname not in index:
        index[fname] = read_spec(fname)
        index.update(flatten(index[fname], file_index))
    return index
  for fname, contents in file_index.items():
    file_index[fname] = read_spec(fname)
    file_index.update(flatten(file_index[fname], file_index))
  return file_index
609694
function promiseReadFiles(pattern) {
  return glob(pattern)
    .then(foundFiles => {
      const promisesToReadFiles = foundFiles.map(fileName => pReadFile(fileName));

      return Promise.all(promisesToReadFiles);
    })
    .catch(log.error);
}
985703
def with_replaced_file(filepath, contents)
      ::Dir.mktmpdir do |temp_dir|
        begin
          temp_path = ::File.join(temp_dir, ::File.basename(filepath))
          ::FileUtils.mkdir_p(::File.dirname(filepath))
          if ::File.file?(filepath)
            ::FileUtils.mv(filepath, temp_path, :force => true)
          end
          ::File.open(filepath, 'w') { |f| f.write(contents) }
          yield
        ensure
          begin
            if ::File.file?(temp_path)
              ::FileUtils.mv(temp_path, filepath, :force => true)
            elsif ::File.file?(filepath)
              ::File.unlink(filepath)
            end
          rescue ::Exception => e
            @logger.note_warning("Failed to restore #{filepath.inspect}: #{e.message}")
          end
        end
      end
    end
1283995
function resolvePaths(processDirectory, cliConfig) {
  logger.debug('resolvePaths', processDirectory, cliConfig);

  const overrides = cliConfig || {};
  // Locate and read package.json
  const packageJsonFile = path.resolve(
    findup.sync(processDirectory, 'package.json'),
    'package.json'
  );
  const baseDir = path.dirname(packageJsonFile);

  const config = Object.assign(
    {},
    getConfigSettings(packageJsonFile, baseDir),
    overrides
  );
  const outputFile = path.resolve(baseDir, config.outputFile);

  const outputFiles = [
    {
      outputFile,
      patterns: config.searchDir.map(dir =>
        path.resolve(baseDir, dir, config.pattern)
      ),
    },
  ];

  const returnValue = {
    outputFiles,
  };
  logger.debug('resolvePaths', returnValue);
  return returnValue;
}
42665
public static List<ContentRepositoryElement> listFiles(final Path rootPath, Path tempDir, final ContentFilter filter) throws IOException {
        List<ContentRepositoryElement> result = new ArrayList<>();
        if (Files.exists(rootPath)) {
            if(isArchive(rootPath)) {
                return listZipContent(rootPath, filter);
            }
            Files.walkFileTree(rootPath, new FileVisitor<Path>() {
                @Override
                public FileVisitResult preVisitDirectory(Path dir, BasicFileAttributes attrs) throws IOException {
                    return FileVisitResult.CONTINUE;
                }

                @Override
                public FileVisitResult visitFile(Path file, BasicFileAttributes attrs) throws IOException {
                    if (filter.acceptFile(rootPath, file)) {
                        result.add(ContentRepositoryElement.createFile(formatPath(rootPath.relativize(file)), Files.size(file)));
                    }
                    return FileVisitResult.CONTINUE;
                }

                @Override
                public FileVisitResult visitFileFailed(Path file, IOException exc) throws IOException {
                    return FileVisitResult.CONTINUE;
                }

                @Override
                public FileVisitResult postVisitDirectory(Path dir, IOException exc) throws IOException {
                    if (filter.acceptDirectory(rootPath, dir)) {
                        String directoryPath = formatDirectoryPath(rootPath.relativize(dir));
                        if(! "/".equals(directoryPath)) {
                            result.add(ContentRepositoryElement.createFolder(directoryPath));
                        }
                    }
                    return FileVisitResult.CONTINUE;
                }

                private String formatDirectoryPath(Path path) {
                    return formatPath(path) + '/';
                }

                private String formatPath(Path path) {
                    return path.toString().replace(File.separatorChar, '/');
                }
            });
        } else {
            Path file = getFile(rootPath);
            if(isArchive(file)) {
                Path relativePath = file.relativize(rootPath);
                Path target = createTempDirectory(tempDir, "unarchive");
                unzip(file, target);
                return listFiles(target.resolve(relativePath), tempDir, filter);
            } else {
                throw new FileNotFoundException(rootPath.toString());
            }
        }
        return result;
    }
941242
function parseStructureFile(book, type) {
    var fs = book.getContentFS();

    return lookupStructureFile(book, type)
    .then(function(file) {
        if (!file) return [undefined, undefined];

        return parseFile(fs, file, type);
    });
}
489177
private File getTempFolder(String tempPath) {
        if (tempPath != null) {
            File folder = new File(tempPath);
            if (folder.exists()) {
                return folder;
            }
        }
        return null;
    }
589075
function resolve(files, opts) {
  var fn = opts.filter || function(fp) {
    return true;
  };

  if (opts.realpath === true) {
    return files.filter(fn);
  }

  var len = files.length;
  var idx = -1;
  var res = [];

  while (++idx < len) {
    var fp = path.resolve(opts.cwd, files[idx]);
    if (!fn(fp) || ~res.indexOf(fp)) continue;
    res.push(fp);
  }
  return res;
}
938371
function resolveImages(currentFile, $) {
    var currentDirectory = path.dirname(currentFile);

    return editHTMLElement($, 'img', function($img) {
        var src = $img.attr('src');

        if (LocationUtils.isExternal(src) || LocationUtils.isDataURI(src)) {
            return;
        }

        // Calcul absolute path for this
        src = LocationUtils.toAbsolute(src, currentDirectory, '.');

        // Convert back to relative
        src = LocationUtils.relative(currentDirectory, src);

        $img.attr('src', src);
    });
}
359294
function resolveImportPaths(filePath, importPaths){
  var dir = path.dirname(filePath);
  return importPaths.map(function(relativePath){
    if(!path.extname(relativePath)){
      relativePath += '.less';
    }
    return path.resolve(dir, relativePath);
  });
}
774729
function resolveSFCs (dirs) {
  return dirs.map(
    layoutDir => readdirSync(layoutDir)
      .filter(filename => filename.endsWith('.vue'))
      .map(filename => {
        const componentName = getComponentName(filename)
        return {
          filename,
          componentName,
          isInternal: isInternal(componentName),
          path: resolve(layoutDir, filename)
        }
      })
  ).reduce((arr, next) => {
    arr.push(...next)
    return arr
  }, []).reduce((map, component) => {
    map[component.componentName] = component
    return map
  }, {})
}
302469
function getFilePaths(strPath = '', exts = ['.css']) {

		if (validUrl.isUri(strPath)){

			switch(exts[0]) {
				case '.css':
					tmpCSSPaths.push(strPath);
					break;
				case '.html':
				case '.htm':
					tmpHTMLPaths.push(strPath);
					break;
				case '.js':
					tmpJSPaths.push(strPath);
					break;
			}
		} else {

			try {
				// Query the entry
				fileStats = fs.lstatSync(strPath);

				// directory given
				if (fileStats.isDirectory()) {

					var dir = strPath;

					//traverse directory for .ext strPath
					try {

						fs.readdirSync(dir).forEach(filenameRead => {

							fileFound = false;

							for (m = 0, count = exts.length; m < count; ++m) {

								if (path.extname(filenameRead) == exts[m]) {
									fileFound = true;
								}
							}

							if (fileFound) {

								switch(exts[0]) {
									case '.css':
										tmpCSSPaths.push(dir + '/' + filenameRead);
										break;
									case '.html':
									case '.htm':
										tmpHTMLPaths.push(dir + '/' + filenameRead);
										break;
									case '.js':
										tmpJSPaths.push(dir + '/' + filenameRead);
										break;
								}

							} else if (path.extname(filenameRead) == '') {

								switch(exts[0]) {
									case '.css':
										getFilePaths(strPath+'/'+filenameRead, ['.css']);
										break;
									case '.html':
									case '.htm':
										getFilePaths(strPath+'/'+filenameRead, ['.html','.htm']);
										break;
									case '.js':
										getFilePaths(strPath+'/'+filenameRead, ['.js']);
										break;
								}

							}
						});



					} catch (e) {
						
						console.log(error("Directory read error: Something went wrong while reading the directory, check your [html] in " + configFileLocation + " and please try again."));
						console.log(e);
						process.exit(1);
					}

				} else if (fileStats.isFile()) { //filepath given

					if (exts.join(",").indexOf(strPath.substr(strPath.lastIndexOf('.') + 1)) != -1) {
						switch(exts[0]) {
							case '.css':
								tmpCSSPaths.push(strPath);
								break;
							case '.html':
							case '.htm':
								tmpHTMLPaths.push(strPath);
								break;
							case '.js':
								tmpJSPaths.push(strPath);
								break;
						}
					}
					
				}
			} catch (e) {
				
				console.log(error("CSS File read error: Something went wrong while reading the file(s), check your [html] in " + configFileLocation + " and please try again."));
				console.log(e);
				process.exit(1);
			}

		} //end of url check
	}
1336984
def load_layout(files, initial = {})
      layout = initial
      Squib::logger.info { "  using layout(s): #{files}" }
      Array(files).each do |file|
        thefile = file
        thefile = builtin(file) unless File.exists?(file)
        if File.exists? thefile
          # note: YAML.load_file returns false on empty file
          yml = layout.merge(YAML.load_file(thefile) || {})
          yml.each do |key, value|
            layout[key] = recurse_extends(yml, key, {})
          end
        else
          Squib::logger.error { "Layout file not found: #{file}. Skipping..." }
        end
      end
      return layout
    end