 
 @param {string} config name of the configuration file
 @param {string} file path to the file to be linted
+@param {boolean} upwards should recurse upwards on failure? (default: true)
+
 @returns {string} a path to the config file
 ###
-findConfig = (config, file) ->
+findConfig = (config, file, upwards=true) ->
   path ?= require("path")
   dir = path.dirname(path.resolve(file))
   envs = getUserHome()
   home = path.normalize(path.join(envs, config))
-  proj = findFile(config, dir)
+  proj = findFile(config, dir, upwards)
   return proj if proj
   return home if verifyExists(home)
   null

  @loadingView.show()
  forceEntireFile = atom.config.get("atom-beautify.beautifyEntireFileOnSave")
  # Look for .jsbeautifierrc in file and home path, check env variables
  getConfig = (startPath) ->
    # Verify that startPath is a string
    startPath = (if (typeof startPath is "string") then startPath else "")
    return {} unless startPath
    # Get the path to the config file
    configPath = findConfig(".jsbeautifyrc", startPath)
    externalOptions = undefined
    if configPath
      fs ?= require("fs")

    indent_char: (if softTabs then " " else "\t")
    indent_with_tabs: not softTabs
  configOptions = getConfigOptionsFromSettings(languages)

  # Get editor path and configurations for paths
  editedFilePath = editor.getPath()

  # Get configuration in User's Home directory
  userHome = getUserHome()
  # FAKEFILENAME forces `path` to treat as file path and it's parent directory
  # is the userHome. See implementation of findConfig
  # and how path.dirname(DIRECTORY) returns the parent directory of DIRECTORY
  homeOptions = getConfig(path.join(userHome,"FAKEFILENAME"), false)

  # TODO: See issue #68. EditorConfig options
  editorConfigOptions = {};

  # Get all options in configuration files from this directory upwards to root
  projectOptions = []
  p = path.dirname(editedFilePath)
  # Check if p is root (top directory)
  while p isnt "/"
    # Get config for p
    pf = path.join(p, "FAKEFILENAME")
    pc = getConfig(pf, false)
    # Add config for p to project's config options
    projectOptions.push(pc)
    # console.log p, pc
    # Move upwards
    p = path.resolve(p,"../")

  # Combine all options together
  allOptions = [
    editorOptions
    configOptions
    homeOptions
    editorConfigOptions
  ]
  allOptions = allOptions.concat(projectOptions)

  # Get current editor's text
  text = undefined
  if not forceEntireFile and isSelection
    text = editor.getSelectedText()
  else
    text = editor.getText()
  oldText = text
  # Get Grammar
  grammarName = editor.getGrammar().name
  # Finally, beautify!
  try
