   #  - File have same basename
   detectFilePath: (filePath) ->
     # Search existing file from file list.
-    if file = _.detect(@getFiles(filePath), (f) -> fs.isFileSync(f))
+    if file = @getFiles(filePath).find((f) -> fs.isFileSync(f))
       return file
 
     # Search file have same basename.
     baseName = getBaseName(filePath)
-    _.detect fs.listSync(path.dirname(filePath)), (f) ->
+    fs.listSync(path.dirname(filePath)).find (f) ->
       (getBaseName(f) is baseName) and fs.isFileSync(f)
 
   getFilePath: (editor, fileName) ->

    {scopeName} = editor.getGrammar()
    filePath = path.resolve(dirName, fileName)
    if hasCommonJSPackageSemantics scopeName, filePath
      potentialIndexFiles = ['index.js', 'index.coffee', 'index.jsx']
      potentialIndexFilePaths = _.map potentialIndexFiles, (indexFile) ->
        path.join(filePath, indexFile)
      potentialIndexFilePath = _.find potentialIndexFilePaths, (indexFilePath) ->
        fs.isFileSync(indexFilePath)
      return potentialIndexFilePath if potentialIndexFilePath

    if filePath = @detectFilePath(path.resolve(dirName, fileName))
      return filePath

_ = require 'underscore-plus'

hasCommonJSPackageSemantics = (scopeName, filePath) ->
  # why use `startsWith` is to make `source.js.jsx` true.
  fs.isDirectorySync(filePath) and (scopeName.startsWith('source.js') or scopeName.startsWith('source.coffee'))

getBaseName = (file) ->
