Skip to content

Commit

Permalink
Don't comment out variables, to avoid errors around unassigned variables
Browse files Browse the repository at this point in the history
  • Loading branch information
gakimball committed Nov 17, 2015
1 parent 90bc756 commit 52e2a96
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 23 deletions.
8 changes: 4 additions & 4 deletions lib/buildSection.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
var commentVariable = require('./commentVariable');
var format = require('util').format;
var repeatChar = require('./repeatChar');
var buildVariable = require('./buildVariable');
var format = require('util').format;
var repeatChar = require('./repeatChar');

module.exports = function(name, num, component) {
var output = '';
Expand All @@ -10,7 +10,7 @@ module.exports = function(name, num, component) {

// Iterate through each variable within the component
for (var i in component) {
output += commentVariable(component[i]);
output += buildVariable(component[i]);
}

output += '\n';
Expand Down
9 changes: 2 additions & 7 deletions lib/commentVariable.js → lib/buildVariable.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,16 +6,11 @@ module.exports = function(variable) {

// Single-line variables
if (value.length === 1) {
output += format('// $%s: %s;\n', variable.context.name, variable.context.value);
output += format('$%s: %s;\n', variable.context.name, variable.context.value);
}
// Multi-line variables (maps)
else {
value = value.map(function(v, i) {
if (i === 0) return v;
return '// ' + v;
});

output += format('// $%s: %s;\n', variable.context.name, value.join('\n'));
output += format('$%s: %s;\n', variable.context.name, value.join('\n'));
}

return output;
Expand Down
24 changes: 12 additions & 12 deletions test/test.js
Original file line number Diff line number Diff line change
Expand Up @@ -98,8 +98,8 @@ describe('Octophant', function(done) {
// 1. Component One
// ----------------
// $variable-one: value;
// $variable-two: value;
$variable-one: value;
$variable-two: value;
*/});
Expand All @@ -108,27 +108,27 @@ describe('Octophant', function(done) {
});
});

describe('commentVariable', function() {
it('adds comment marks to single-line a Sass variable', function() {
var actual = require('../lib/commentVariable')({
describe('buildVariable', function() {
it('formats a single-line a Sass variable', function() {
var actual = require('../lib/buildVariable')({
context: { name: 'name', value: 'value' }
});

var expected = '// $name: value;\n';
var expected = '$name: value;\n';

assert.equal(expected, actual);
});

it('adds comment marks to every line in a multi-line Sass variable', function() {
var actual = require('../lib/commentVariable')({
it('formats a multi-line Sass variable', function() {
var actual = require('../lib/buildVariable')({
context: { name: 'name', value: '(\n one: one,\n two: two,\n)' }
});

var expected = multiline.stripIndent(function() {/*
// $name: (
// one: one,
// two: two,
// );
$name: (
one: one,
two: two,
);
*/});

Expand Down

0 comments on commit 52e2a96

Please sign in to comment.