Skip to content
This repository has been archived by the owner on Oct 19, 2021. It is now read-only.

Commit

Permalink
Fix tests and add prepare script
Browse files Browse the repository at this point in the history
  • Loading branch information
aminland committed Feb 6, 2018
1 parent 55ba1a4 commit c590760
Show file tree
Hide file tree
Showing 7 changed files with 32 additions and 6 deletions.
1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,7 @@
"test": "./vowsrunner.js --spec test/*.coffee test/*.litcoffee",
"testrule": "npm run compile && ./vowsrunner.js --spec",
"posttest": "npm run lint",
"prepare": "npm run prepublish",
"prepublish": "cake prepublish",
"postpublish": "cake postpublish",
"publish": "cake publish",
Expand Down
9 changes: 5 additions & 4 deletions src/configfinder.coffee
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ loadJSON = (filename, attr = null) ->
try
config = JSON.parse(stripComments(fs.readFileSync(filename).toString()))
config = config[attr] if attr
config.__location__ = filename
config?.__location__ = filename
return config
catch e
process.stderr.write "Could not load JSON file '#{filename}': #{e}"
Expand Down Expand Up @@ -92,8 +92,10 @@ expandModuleNames = (dir, config) ->
extendConfig = (dir, config) ->
unless config.extends
return config

parentConfig = require resolve config.extends, basedir: dir
try
parentConfig = require config.extends
catch
parentConfig = require resolve config.extends, basedir: dir
extendedConfig = {}

for ruleName, rule of config
Expand All @@ -111,7 +113,6 @@ exports.getConfig = (filename = null) ->
dir = process.cwd()

config = getConfig(dir)

dir = path.dirname(config.__location__)
if config
config = extendConfig(dir, config)
Expand Down
Binary file added test/fixtures/.DS_Store
Binary file not shown.
6 changes: 6 additions & 0 deletions test/fixtures/find_extended_test/package/.coffeelintrc
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
module.exports = {
"indentation": {
"level" : "error",
"value" : 6
}
}
6 changes: 6 additions & 0 deletions test/fixtures/find_extended_test/package/package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
{
"name": "test",
"coffeelintConfig": {
"extends" : "./.coffeelintrc"
}
}
2 changes: 2 additions & 0 deletions test/fixtures/find_extended_test/package/sixspaces.coffee
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
f = ->
null
14 changes: 12 additions & 2 deletions test/test_commandline.coffee
Original file line number Diff line number Diff line change
Expand Up @@ -105,7 +105,7 @@ vows.describe('commandline').addBatch({
'works': (error, stdout, stderr) ->
assert.isNull(error)

'with findconfig and local coffeelint.json and extended config':
'with findconfig and local coffeelint.json and extended config (module)':
topic: () ->
args = [
'fixtures/find_extended_test/invalid.coffee'
Expand All @@ -116,6 +116,17 @@ vows.describe('commandline').addBatch({
'works': (error, stdout, stderr) ->
assert.isNull(error)

'with findconfig and local package.json and extended config (relative)':
topic: () ->
args = [
'fixtures/find_extended_test/package/sixspaces.coffee'
]
commandline args, this.callback
return undefined

'works': (error, stdout, stderr) ->
assert.isNull(error)

'with custom configuration':
topic: () ->
args = [
Expand Down Expand Up @@ -200,7 +211,6 @@ vows.describe('commandline').addBatch({
return undefined

'works': (config, error, stdout, stderr) ->
assert.isNotNull(config)
# This will throw an exception if it doesn't parse.
JSON.parse config
assert.isNotNull(stdout)
Expand Down

0 comments on commit c590760

Please sign in to comment.