Comparing version 0.3.1 to 0.4.0
@@ -102,12 +102,17 @@ #!/usr/bin/env node | ||
configPath = resolveConfigPath(configPath); | ||
let config = loadLocalConfigUnmodified(configPath); | ||
if (!config) { | ||
config = loadLocalConfigWithJs(configPath); | ||
let config; | ||
try { | ||
config = loadLocalConfigUnmodified(configPath); | ||
if (!config) { | ||
config = loadLocalConfigWithJs(configPath); | ||
} | ||
if (!config) { | ||
config = loadLocalConfigWithJson(configPath); | ||
} | ||
if (program.config && !config) { | ||
return reject(new Error(`The config file "${configPath}" could not be loaded`)); | ||
} | ||
} catch (error) { | ||
return reject(new Error(`There was a problem loading "${configPath}":\n${error.stack}`)); | ||
} | ||
if (!config) { | ||
config = loadLocalConfigWithJson(configPath); | ||
} | ||
if (program.config && !config) { | ||
return reject(new Error(`The config file "${configPath}" could not be loaded`)); | ||
} | ||
resolve(defaultConfig(config || {})); | ||
@@ -133,3 +138,7 @@ }); | ||
return JSON.parse(fs.readFileSync(configPath, 'utf-8')); | ||
} catch (error) {} | ||
} catch (error) { | ||
if (error.code !== 'ENOENT') { | ||
throw error; | ||
} | ||
} | ||
} | ||
@@ -141,3 +150,7 @@ | ||
return require(`${configPath}.js`); | ||
} catch (error) {} | ||
} catch (error) { | ||
if (error.code !== 'MODULE_NOT_FOUND') { | ||
throw error; | ||
} | ||
} | ||
} | ||
@@ -149,3 +162,7 @@ | ||
return require(`${configPath}.json`); | ||
} catch (error) {} | ||
} catch (error) { | ||
if (error.code !== 'MODULE_NOT_FOUND') { | ||
throw error; | ||
} | ||
} | ||
} | ||
@@ -152,0 +169,0 @@ |
# Changelog | ||
## 0.4.0 pre-release (2016-12-05) | ||
* Exit with an error if config files have syntax errors | ||
## 0.3.1 pre-release (2016-11-30) | ||
@@ -5,0 +9,0 @@ |
{ | ||
"name": "pa11y-ci", | ||
"version": "0.3.1", | ||
"version": "0.4.0", | ||
"description": "The Pa11y CI application", | ||
@@ -5,0 +5,0 @@ "keywords": [], |
@@ -129,4 +129,6 @@ | ||
To contribute to Pa11y CI, clone this repo locally and commit your code on a new branch. | ||
There are many ways to contribute to Pa11y CI, we cover these in the [contributing guide](CONTRIBUTING.md) for this repo. | ||
If you're ready to contribute some code, clone this repo locally and commit your code on a new branch. | ||
Please write unit tests for your code, and check that everything works by running the following before opening a <abbr title="pull request">PR</abbr>: | ||
@@ -133,0 +135,0 @@ |
@@ -92,1 +92,61 @@ // jscs:disable maximumLineLength | ||
}); | ||
describe('pa11y-ci (with a config file that has no extension and syntax errors)', () => { | ||
before(() => { | ||
return global.cliCall([ | ||
'--config', | ||
'syntax-errors' | ||
]); | ||
}); | ||
it('exits with 1', () => { | ||
assert.strictEqual(global.lastResult.code, 1); | ||
}); | ||
it('outputs an error message', () => { | ||
assert.include(global.lastResult.output, 'There was a problem loading'); | ||
assert.include(global.lastResult.output, 'syntax-errors'); | ||
}); | ||
}); | ||
describe('pa11y-ci (with a config file that has a "json" extension and syntax errors)', () => { | ||
before(() => { | ||
return global.cliCall([ | ||
'--config', | ||
'syntax-errors-json' | ||
]); | ||
}); | ||
it('exits with 1', () => { | ||
assert.strictEqual(global.lastResult.code, 1); | ||
}); | ||
it('outputs an error message', () => { | ||
assert.include(global.lastResult.output, 'There was a problem loading'); | ||
assert.include(global.lastResult.output, 'syntax-errors-json'); | ||
}); | ||
}); | ||
describe('pa11y-ci (with a config file that has a "js" extension and syntax errors)', () => { | ||
before(() => { | ||
return global.cliCall([ | ||
'--config', | ||
'syntax-errors-js' | ||
]); | ||
}); | ||
it('exits with 1', () => { | ||
assert.strictEqual(global.lastResult.code, 1); | ||
}); | ||
it('outputs an error message', () => { | ||
assert.include(global.lastResult.output, 'There was a problem loading'); | ||
assert.include(global.lastResult.output, 'syntax-errors-js'); | ||
}); | ||
}); |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
New author
Supply chain riskA new npm collaborator published a version of the package for the first time. New collaborators are usually benign additions to a project, but do indicate a change to the security surface area of a package.
Found 1 instance in 1 package
65701
56
1223
173
3