// replace color name with hex values if shorter (or the other way around)
['toHex', 'toName'].forEach(function(type) {
- var pattern = "(" + Object.keys(CleanCSS.colors[type]).join('|') + ")";
+ var pattern = '(' + Object.keys(CleanCSS.colors[type]).join('|') + ')';
var colorSwitcher = function(match, prefix, colorValue, suffix) {
return prefix + CleanCSS.colors[type][colorValue.toLowerCase()] + suffix;
};
- replace(new RegExp("([ :,\\(])" + pattern + "([;\\}!\\) ])", 'ig'), colorSwitcher);
- replace(new RegExp("(,)" + pattern + "(,)", 'ig'), colorSwitcher);
+ replace(new RegExp('([ :,\\(])' + pattern + '([;\\}!\\) ])', 'ig'), colorSwitcher);
+ replace(new RegExp('(,)' + pattern + '(,)', 'ig'), colorSwitcher);
});
// replace font weight with numerical value
// restore 0% in hsl/hsla
replace(/(hsl|hsla)\(([^\)]+)\)/g, function(match, colorFunction, colorDef) {
var tokens = colorDef.split(',');
- if (tokens[1] == "0")
+ if (tokens[1] == '0')
tokens[1] = '0%';
- if (tokens[2] == "0")
+ if (tokens[2] == '0')
tokens[2] = '0%';
- return colorFunction + "(" + tokens.join(',') + ")";
+ return colorFunction + '(' + tokens.join(',') + ')';
});
// none to 0
// shorthand notations
var shorthandRegex = function(repeats, hasSuffix) {
- var pattern = "(padding|margin|border\\-width|border\\-color|border\\-style|border\\-radius):";
+ var pattern = '(padding|margin|border\\-width|border\\-color|border\\-style|border\\-radius):';
for (var i = 0; i < repeats; i++) {
- pattern += "([\\d\\w\\.%#\\(\\),]+)" + (i < repeats - 1 ? ' ' : '');
+ pattern += '([\\d\\w\\.%#\\(\\),]+)' + (i < repeats - 1 ? ' ' : '');
}
return new RegExp(pattern + (hasSuffix ? '([;}])' : ''), 'g');
};
// same 2 values into one
replace(shorthandRegex(2, true), function(match, property, size1, size2, suffix) {
if (size1 === size2)
- return property + ":" + size1 + suffix;
+ return property + ':' + size1 + suffix;
else
return match;
});
'version': binaryContext('-v', {
'should output help': function(error, stdout) {
var version = JSON.parse(fs.readFileSync('./package.json')).version;
- assert.equal(stdout, version + "\n");
+ assert.equal(stdout, version + '\n');
}
}),
- 'stdin': pipedContext("a{color: #f00}", '', {
+ 'stdin': pipedContext('a{color: #f00}', '', {
'should output data': function(error, stdout) {
- assert.equal(stdout, "a{color:red}");
+ assert.equal(stdout, 'a{color:red}');
}
}),
'no empty by default': pipedContext('a{}', '', {
'should preserve content': function(error, stdout) {
- assert.equal(stdout, "a{}");
+ assert.equal(stdout, 'a{}');
}
}),
'strip all but first comment': pipedContext('/*!1st*//*! 2nd */a{}', '--s1', {
'should keep the 2nd comment': function(error, stdout) {
- assert.equal(stdout, "/*!1st*/a{}");
+ assert.equal(stdout, '/*!1st*/a{}');
}
}),
'strip all comments': pipedContext('/*!1st*//*! 2nd */a{}', '--s0', {
'should keep the 2nd comment': function(error, stdout) {
- assert.equal(stdout, "a{}");
+ assert.equal(stdout, 'a{}');
}
}),
'empty': pipedContext('a{}', '-e', {
'should preserve content': function(error, stdout) {
- assert.equal(stdout, "");
+ assert.equal(stdout, '');
}
}),
'no relative to path': binaryContext('./test/data/partials-absolute/base.css', {
'should not be able to resolve it fully': function(error, stdout) {
- assert.equal(stdout, ".sub{padding:0}.base{margin:0}");
+ assert.equal(stdout, '.sub{padding:0}.base{margin:0}');
}
}),
'relative to path': binaryContext('-r ./test/data ./test/data/partials-absolute/base.css', {
'should be able to resolve it': function(error, stdout) {
- assert.equal(stdout, ".base2{border-width:0}.sub{padding:0}.base{margin:0}");
+ assert.equal(stdout, '.base2{border-width:0}.sub{padding:0}.base{margin:0}');
}
}),
'from source': binaryContext('./test/data/reset.css', {
'div{height:-moz-calc(3 * 2em + 10px)}'
],
'before colon': [
- "#test{padding-left :0}",
- "#test{padding-left:0}"
+ '#test{padding-left :0}',
+ '#test{padding-left:0}'
],
- 'before colon but not selectors #1': "div :before{}",
- 'before colon but not selectors #2': "div ::-webkit-search-decoration{}",
- 'before colon but not selectors #3': "div :after{color:red}",
+ 'before colon but not selectors #1': 'div :before{}',
+ 'before colon but not selectors #2': 'div ::-webkit-search-decoration{}',
+ 'before colon but not selectors #3': 'div :after{color:red}',
'windows breaks': [
'div>a{color:red\r\n }',
'div>a{color:red}'