diff --git a/bin/suitcss b/bin/suitcss index 6208c77..e3a296a 100755 --- a/bin/suitcss +++ b/bin/suitcss @@ -117,16 +117,20 @@ function run() { read(input, function(err, buffer) { if (err) logger.throw(err); var css = buffer.toString(); + var optsAliases = { + importRoot: 'root' + }; var flags = [ 'minify', 'encapsulate', - 'root', + 'importRoot', 'lint' - ].reduce(function (accumulator, flag) { - if (({}).hasOwnProperty.call(program, flag)) { - accumulator[flag] = program[flag]; + ].reduce(function(acc, inFlag) { + if (({}).hasOwnProperty.call(program, inFlag)) { + var flag = optsAliases[inFlag] || inFlag; + acc[flag] = program[inFlag]; } - return accumulator; + return acc; }, {}); var opts = assign({}, config, flags); diff --git a/test/cli.js b/test/cli.js index 3de6f79..aefe190 100644 --- a/test/cli.js +++ b/test/cli.js @@ -133,5 +133,20 @@ describe('cli', function() { done(); }); }); -}); + describe('--importRoot', function() { + it('should be able to override root in a config file with importRoot', function(done) { + exec('node bin/suitcss -c test/config/root-fake.js -i ./test/fixtures ./test/fixtures/import.css test/fixtures/cli/output.css', function(err) { + expect(err).to.be.null; + done(); + }); + }); + + it('should use the config root option if importRoot is undefined', function(done) { + exec('node bin/suitcss -c test/config/root-real.js ./test/fixtures/import.css test/fixtures/cli/output.css', function(err) { + expect(err).to.be.null; + done(); + }); + }); + }); +}); diff --git a/test/config/root-fake.js b/test/config/root-fake.js new file mode 100644 index 0000000..b33eb8b --- /dev/null +++ b/test/config/root-fake.js @@ -0,0 +1,3 @@ +module.exports = { + root: './foo/bar' +}; diff --git a/test/config/root-real.js b/test/config/root-real.js new file mode 100644 index 0000000..2dace35 --- /dev/null +++ b/test/config/root-real.js @@ -0,0 +1,3 @@ +module.exports = { + root: './test/fixtures' +};