Skip to content

Commit 487a79e

Browse files
simonsmithgiuseppeg
authored andcommitted
Allow --importRoot to override root config option (#70)
1 parent 9b4e480 commit 487a79e

File tree

4 files changed

+31
-6
lines changed

4 files changed

+31
-6
lines changed

bin/suitcss

+9-5
Original file line numberDiff line numberDiff line change
@@ -117,16 +117,20 @@ function run() {
117117
read(input, function(err, buffer) {
118118
if (err) logger.throw(err);
119119
var css = buffer.toString();
120+
var optsAliases = {
121+
importRoot: 'root'
122+
};
120123
var flags = [
121124
'minify',
122125
'encapsulate',
123-
'root',
126+
'importRoot',
124127
'lint'
125-
].reduce(function (accumulator, flag) {
126-
if (({}).hasOwnProperty.call(program, flag)) {
127-
accumulator[flag] = program[flag];
128+
].reduce(function(acc, inFlag) {
129+
if (({}).hasOwnProperty.call(program, inFlag)) {
130+
var flag = optsAliases[inFlag] || inFlag;
131+
acc[flag] = program[inFlag];
128132
}
129-
return accumulator;
133+
return acc;
130134
}, {});
131135
var opts = assign({}, config, flags);
132136

test/cli.js

+16-1
Original file line numberDiff line numberDiff line change
@@ -133,5 +133,20 @@ describe('cli', function() {
133133
done();
134134
});
135135
});
136-
});
137136

137+
describe('--importRoot', function() {
138+
it('should be able to override root in a config file with importRoot', function(done) {
139+
exec('node bin/suitcss -c test/config/root-fake.js -i ./test/fixtures ./test/fixtures/import.css test/fixtures/cli/output.css', function(err) {
140+
expect(err).to.be.null;
141+
done();
142+
});
143+
});
144+
145+
it('should use the config root option if importRoot is undefined', function(done) {
146+
exec('node bin/suitcss -c test/config/root-real.js ./test/fixtures/import.css test/fixtures/cli/output.css', function(err) {
147+
expect(err).to.be.null;
148+
done();
149+
});
150+
});
151+
});
152+
});

test/config/root-fake.js

+3
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
module.exports = {
2+
root: './foo/bar'
3+
};

test/config/root-real.js

+3
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
module.exports = {
2+
root: './test/fixtures'
3+
};

0 commit comments

Comments
 (0)