Skip to content
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.

Commit feebb83

Browse files
committedOct 4, 2015
Add Config File option for passed in options
Resolves sasstools#226
1 parent 05a51a3 commit feebb83

File tree

3 files changed

+28
-0
lines changed

3 files changed

+28
-0
lines changed
 

‎docs/options/config-file.md

+5
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
# Config File
2+
3+
Option `config-file` will tell Sass Lint the path to a custom config file. `config-file` should be set to a path plus file name relative to where Sass Lint is being run from. If not included, Sass Lint will attempt to find the closest config file, or fall back to the default one.
4+
5+
Config File will only be respected if passed in as an option directly, not if it is already in a config file.

‎lib/config.js

+4
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,10 @@ module.exports = function (options, configPath) {
4040

4141
options = options ? options : {};
4242

43+
if (options.options && options.options['config-file']) {
44+
configPath = options.options['config-file'];
45+
}
46+
4347
if (!configPath) {
4448
metaPath = findFile(false, 'package.json');
4549
meta = require(metaPath);

‎tests/config.js

+19
Original file line numberDiff line numberDiff line change
@@ -60,6 +60,25 @@ describe('config', function () {
6060
done();
6161
});
6262

63+
it('should use a config file if one is provided', function (done) {
64+
var conf = config({
65+
'options': {
66+
'config-file': 'tests/yml/.stylish-output.yml'
67+
}
68+
}),
69+
merged = merge.recursive(defaults, fs.readFileSync(path.join(__dirname, 'yml', '.stylish-output.yml')));
70+
71+
equal(
72+
conf,
73+
merged,
74+
{
75+
'strict': true
76+
}
77+
);
78+
79+
done();
80+
});
81+
6382
it('should not merge rules when `merge-default-rules` is false', function (done) {
6483
var opts = options,
6584
conf,

0 commit comments

Comments
 (0)
Please sign in to comment.