GitHub

@@ -25,6 +25,22 @@ findFile = (name, dir) ->

2525

else

2626

findFile name, parent

272728+

findAnyFile = (names, dir) ->

29+

dir = dir or process.cwd()

30+

parent = path.resolve(dir, '../')

31+

filepath = ''

32+

for filename in names

33+

filepath = path.normalize(path.join(dir, filename))

34+

if findFileResults[filepath]

35+

return findFileResults[filepath]

36+

if fs.existsSync(filepath)

37+

findFileResults[filepath] = filepath

38+

return findFileResults[filepath]

39+

if dir is parent

40+

findFileResults[filepath] = null

41+

else

42+

findAnyFile names, parent

43+2844

# Possibly find CoffeeLint configuration within a package.json file.

2945

loadNpmConfig = (dir) ->

3046

fp = findFile('package.json', dir)

@@ -49,19 +65,21 @@ loadJSON = (filename, attr = null) ->

4965

# specific 'coffeelint.json' or a global 'coffeelint.json' in the home

5066

# directory.

5167

getConfig = (dir) ->

52-

if (process.env.COFFEELINT_CONFIG and

53-

fs.existsSync(process.env.COFFEELINT_CONFIG))

68+

if (process.env.COFFEELINT_CONFIG and fs.existsSync(process.env.COFFEELINT_CONFIG))

5469

return loadJSON(process.env.COFFEELINT_CONFIG)

55705671

npmConfig = loadNpmConfig(dir)

57-

return npmConfig if npmConfig

58-

projConfig = findFile('coffeelint.json', dir)

59-

return loadJSON(projConfig) if projConfig

60-61-

envs = process.env.USERPROFILE or process.env.HOME or process.env.HOMEPATH

62-

home = path.normalize(path.join(envs, 'coffeelint.json'))

63-

if fs.existsSync(home)

64-

return loadJSON(home)

72+

if npmConfig

73+

return npmConfig

74+75+

projectConfig = findAnyFile(['coffeelint.json', '.coffeelintrc.json'], dir)

76+

if projectConfig

77+

return loadJSON(projectConfig)

78+79+

homePath = process.env.USERPROFILE or process.env.HOME or process.env.HOMEPATH

80+

homeConfig = path.normalize(path.join(homePath, 'coffeelint.json'))

81+

if fs.existsSync(homeConfig)

82+

return loadJSON(homeConfig)

65836684

# configfinder is the only part of coffeelint that actually has the full

6785

# filename and can accurately resolve module names. This will find all of the

Read the original on github.com ↗