Comparing version 1.3.1 to 1.4.0
#!/usr/bin/env node | ||
var path = require('path'), | ||
fs = require('fs'), | ||
sys = require('util'), | ||
chalk = require('chalk'), | ||
mkdirp = require('mkdirp'), | ||
rtlcss = require('../lib/rtlcss'), | ||
configLoader = require('../lib/config-loader'), | ||
chalk = require('chalk'); | ||
configLoader = require('../lib/config-loader') | ||
; | ||
var shouldBreak = false, inputFile,outputFile,config; | ||
var currentErrorcode, arg, args = process.argv.slice(2); | ||
var input, output, directory, | ||
config, silent, currentErrorcode, | ||
arg, args = process.argv.slice(2), | ||
shouldBreak = false | ||
; | ||
@@ -15,151 +21,234 @@ process.on('exit', function() { process.reallyExit(currentErrorcode) }); | ||
function printWarning (){ | ||
console.log(chalk.yellow.apply(this,printWarning.arguments)); | ||
console.log(chalk.yellow.apply(this,printWarning.arguments)); | ||
} | ||
function printInfo (){ | ||
console.log(chalk.green.apply(this,printInfo.arguments)); | ||
console.log(chalk.green.apply(this,printInfo.arguments)); | ||
} | ||
function printError (){ | ||
console.log(chalk.red.apply(this,printError.arguments)); | ||
console.log(chalk.red.apply(this,printError.arguments)); | ||
} | ||
function printHelp(){ | ||
console.log('Usage: rtlcss [option option=parameter ...] [source] [destination]'); | ||
console.log(''); | ||
var options = | ||
[ | ||
'Option ' ,'Description ', | ||
'--------------','----------------------------------------------', | ||
'-h,--help' ,'Print help (this message) and exit.', | ||
'-v,--version' ,'Print version number and exit.', | ||
'-c,--config' ,'Path to configuration settings file.', | ||
'- ,--stdin' ,'RTLCSS will read from stdin stream.' | ||
]; | ||
function printHelp(){ | ||
console.log('Usage: rtlcss [option option=parameter ...] [source] [destination]'); | ||
console.log(''); | ||
var options = | ||
[ | ||
'Option ' , 'Description ', | ||
'--------------' , '----------------------------------------------', | ||
'-h,--help' , 'Print help (this message) and exit.', | ||
'-v,--version' , 'Print version number and exit.', | ||
'-c,--config' , 'Path to configuration settings file.', | ||
'- ,--stdin' , 'Read from stdin stream.', | ||
'-d,--dirctory' , 'Process all *.css files from input directory (recursive).', | ||
'-s,--silent' , 'Silent mode, no warnings or errors are printed.' | ||
]; | ||
for(var x=0;x<options.length;x++) | ||
console.log(options[x++],'\t',options[x]); | ||
console.log(''); | ||
console.log('*If no destination is specified, output will written to {source name}.rtl.{ext} '); | ||
console.log(''); | ||
printInfo('RTLCSS version: ' + require('../package.json').version); | ||
printInfo('Report issues to: https://github.com/MohammadYounes/rtlcss/issues'); | ||
for(var x=0;x<options.length;x++){ | ||
console.log(options[x++],'\t',options[x]); | ||
} | ||
console.log(''); | ||
console.log('*If no destination is specified, output will be written to the same input folder as {source}.rtl.{ext}'); | ||
console.log(''); | ||
printInfo('RTLCSS version: ' + require('../package.json').version); | ||
printInfo('Report issues to: https://github.com/MohammadYounes/rtlcss/issues'); | ||
} | ||
while(arg = args.shift()){ | ||
switch(arg){ | ||
case '-h': | ||
case '--help': | ||
printHelp(); | ||
shouldBreak = true; | ||
break; | ||
case '-v': | ||
case '--version': | ||
printInfo('rtlcss version: ' + require('../package.json').version); | ||
shouldBreak = true; | ||
break; | ||
case '-c': | ||
case '--config': | ||
arg = args.shift(); | ||
try | ||
{ | ||
config = configLoader.load(path.resolve(arg)); | ||
} | ||
catch(e) | ||
{ | ||
printError('rtlcss: invalid config file. ', e); | ||
shouldBreak = true; | ||
currentErrorcode = 1; | ||
} | ||
break; | ||
case '-': | ||
case '--stdin': | ||
inputFile = '-'; | ||
break; | ||
default: | ||
if(arg[0] == '-'){ | ||
printError('rtlcss: unknown option. ' + arg); | ||
shouldBreak = true; | ||
}else{ | ||
if(!inputFile) | ||
inputFile = path.resolve(arg); | ||
else if(!outputFile) | ||
outputFile = path.resolve(arg); | ||
} | ||
break; | ||
} | ||
switch(arg){ | ||
case '-h': | ||
case '--help': | ||
printHelp(); | ||
shouldBreak = true; | ||
break; | ||
case '-v': | ||
case '--version': | ||
printInfo('rtlcss version: ' + require('../package.json').version); | ||
shouldBreak = true; | ||
break; | ||
case '-c': | ||
case '--config': | ||
arg = args.shift(); | ||
try | ||
{ | ||
config = configLoader.load(path.resolve(arg)); | ||
} | ||
catch(e) | ||
{ | ||
printError('rtlcss: invalid config file. ', e); | ||
shouldBreak = true; | ||
currentErrorcode = 1; | ||
} | ||
break; | ||
case '-d': | ||
case '--directory': | ||
directory = true; | ||
break; | ||
case '-s': | ||
case '--silent': | ||
console.log = function(){}; | ||
break; | ||
case '-': | ||
case '--stdin': | ||
input = '-'; | ||
break; | ||
default: | ||
if(arg[0] == '-'){ | ||
printError('rtlcss: unknown option. ' + arg); | ||
shouldBreak = true; | ||
}else{ | ||
if(!input) | ||
input = path.resolve(arg); | ||
else if(!output) | ||
output = path.resolve(arg); | ||
} | ||
break; | ||
} | ||
} | ||
if(shouldBreak) | ||
return; | ||
if(shouldBreak){ | ||
return; | ||
} | ||
if (!inputFile) { | ||
printError('rtlcss: no input file'); | ||
console.log(''); | ||
printHelp(); | ||
if (!directory && !input) { | ||
printError('rtlcss: no input file'); | ||
console.log(''); | ||
printHelp(); | ||
return; | ||
} | ||
if(!config && input !== '-'){ | ||
try | ||
{ | ||
var cwd = input; | ||
if(directory !== true){ | ||
cwd = path.dirname(input); | ||
} | ||
config = configLoader.load(null, cwd); | ||
}catch(e){ | ||
printError('rtlcss: invalid config file. ', e); | ||
currentErrorcode = 1; | ||
return; | ||
} | ||
} | ||
if(!config && inputFile !== '-'){ | ||
try{ | ||
config = configLoader.load(null, path.dirname(inputFile)); | ||
}catch(e){ | ||
printError('rtlcss: invalid config file. ', e); | ||
currentErrorcode = 1; | ||
return; | ||
} | ||
if(!output && input !== '-'){ | ||
if(directory !== true){ | ||
output = path.extname(input) ? input.replace(/\.[^.]*$/, function(ext){ return '.rtl' + ext;}) : input + '.rtl'; | ||
} | ||
else{ | ||
output = input; | ||
} | ||
} | ||
if(!outputFile && inputFile !== '-') | ||
outputFile = path.extname(inputFile) ? inputFile.replace(/\.[^.]*$/, function(ext){ return '.rtl' + ext;}) : inputFile + '.rtl'; | ||
var processCSSFile = function (e, data) { | ||
if (e) { | ||
printError('rtlcss: ' + e.message); | ||
return; | ||
var processCSSFile = function (e, data, outputName) { | ||
if (e) { | ||
printError('rtlcss: ' + e.message); | ||
return; | ||
} | ||
var result, opt = { map: undefined, from:undefined, to:undefined}; | ||
if(!config){ | ||
printWarning('rtlcss: Warning! No config present, using defaults.'); | ||
result = rtlcss().process(data, opt); | ||
}else{ | ||
if(config.map === true && input !== '-'){ | ||
opt.map = config.map; | ||
opt.from = input; | ||
opt.to = output; | ||
} | ||
var result, opt = { map: undefined, from:undefined, to:undefined}; | ||
if(!config){ | ||
printWarning('rtlcss: Warning! No config present, using defaults.'); | ||
result = rtlcss().process(data, opt); | ||
}else{ | ||
if(config.map === true && inputFile !== '-'){ | ||
opt.map = config.map; | ||
opt.from = inputFile; | ||
opt.to = outputFile; | ||
} | ||
result = rtlcss(config.options, | ||
config.rules, | ||
config.declarations, | ||
config.properties).process(data, opt); | ||
} | ||
result = rtlcss(config.options, | ||
config.rules, | ||
config.declarations, | ||
config.properties).process(data, opt); | ||
} | ||
if (outputFile) { | ||
fs.writeFileSync(outputFile, result.css, 'utf8'); | ||
if(opt.map == true){ | ||
fs.writeFileSync(outputFile + '.map', result.map, 'utf8'); | ||
} | ||
} else { | ||
sys.print(result.css); | ||
if (output) { | ||
var savePath = outputName; | ||
if(directory !== true){ | ||
savePath = output; | ||
} | ||
printInfo('Saving:', savePath); | ||
fs.writeFile(savePath, result.css, 'utf8', function(err){ err && printError(err); }); | ||
if(opt.map == true){ | ||
fs.writeFile(savePath + '.map', result.map, 'utf8', function(err){ err && printError(err); } ); | ||
} | ||
} else { | ||
sys.print(result.css); | ||
} | ||
}; | ||
if (inputFile != '-') { | ||
fs.readFile(inputFile, 'utf8', processCSSFile); | ||
var walk = function(dir, done) { | ||
fs.readdir(dir, function (error, list) { | ||
if (error) { | ||
return done(error); | ||
} | ||
var i = 0; | ||
(function next() { | ||
var file = list[i++]; | ||
if (!file) { | ||
return done(null); | ||
} | ||
file = dir + path.sep + file; | ||
fs.stat(file, function (error, stat) { | ||
if (stat && stat.isDirectory()) { | ||
walk(file, function (error) { | ||
next(); | ||
}); | ||
} else { | ||
//process only *.css | ||
if (/\.(css)$/.test(file)) { | ||
//compute output directory | ||
var relativePath = path.relative(input,file).split(path.sep); | ||
relativePath.pop(); | ||
relativePath.push(path.basename(file).replace(".css", ".rtl.css")); | ||
//set rtl file name | ||
var rtlFile = path.join(output,relativePath.join(path.sep)); | ||
//create output directory if it does not exist | ||
var dirName = path.dirname(rtlFile); | ||
if(!fs.existsSync(dirName)) | ||
mkdirp.sync(dirName); | ||
//read and process the file. | ||
fs.readFile(file, 'utf8',function(e,data){ processCSSFile(e,data,rtlFile);}); | ||
} | ||
next(); | ||
} | ||
}); | ||
})(); | ||
}); | ||
}; | ||
if (input != '-') { | ||
if(directory !== true){ | ||
fs.stat(input, function (error, stat) { | ||
if (stat && stat.isDirectory()){ | ||
printError('rtlcss: Input expected to be a file, use -d option to process a directory.'); | ||
}else{ | ||
fs.readFile(input, 'utf8', processCSSFile); | ||
} | ||
}); | ||
}else{ | ||
walk(input, function(error){ | ||
if(error) | ||
printError('rtlcss: '+ error); | ||
}); | ||
} | ||
} else { | ||
process.stdin.resume(); | ||
process.stdin.setEncoding('utf8'); | ||
process.stdin.resume(); | ||
process.stdin.setEncoding('utf8'); | ||
var buffer = ''; | ||
process.stdin.on('data', function(data) { | ||
buffer += data; | ||
}); | ||
process.on('SIGINT', function(){ | ||
processCSSFile(false, buffer); | ||
process.exit(); | ||
}); | ||
process.stdin.on('end', function() { | ||
processCSSFile(false, buffer); | ||
}); | ||
var buffer = ''; | ||
process.stdin.on('data', function(data) { | ||
buffer += data; | ||
}); | ||
process.on('SIGINT', function(){ | ||
processCSSFile(false, buffer); | ||
process.exit(); | ||
}); | ||
process.stdin.on('end', function() { | ||
processCSSFile(false, buffer); | ||
}); | ||
} |
16
CLI.md
@@ -82,6 +82,14 @@ RTLCSS CLI | ||
### Directory | ||
Used to indicate input is a directory and not a file. | ||
``` | ||
$ rtlcss -d | ||
$ rtlcss --directory | ||
``` | ||
### Silent | ||
Silent mode, no warnings or errors will be printed. | ||
``` | ||
$ rtlcss -s | ||
$ rtlcss --silent | ||
``` |
var fs = require('fs'), | ||
path = require('path'), | ||
findup = require('findup'), | ||
stripJSONComments = require('strip-json-comments'); | ||
path = require('path'), | ||
findup = require('findup'), | ||
stripJSONComments = require('strip-json-comments'); | ||
@@ -10,78 +10,71 @@ var configSources = ['package.json', '.rtlcssrc', '.rtlcss.json']; | ||
for(var x=0;x<configSources.length;x++){ | ||
var found, source = configSources[x]; | ||
try | ||
{ | ||
found = findup.sync(dir,source); | ||
} | ||
catch(e) { | ||
continue; | ||
} | ||
if(found){ | ||
var configFilePath = path.normalize(path.join(found, source)); | ||
try | ||
{ | ||
config = JSON.parse( | ||
stripJSONComments( | ||
fs.readFileSync(configFilePath,'utf-8').trim() | ||
) | ||
); | ||
}catch(e){ | ||
throw new Error(e + ' ' + configFilePath); | ||
} | ||
if(source == 'package.json'){ | ||
config = config.rtlcssConfig; | ||
} | ||
if(config) | ||
return config; | ||
} | ||
} | ||
for (var x = 0; x < configSources.length; x++) { | ||
var found, source = configSources[x]; | ||
try { | ||
found = findup.sync(dir, source); | ||
} | ||
catch (e) { | ||
continue; | ||
} | ||
if (found) { | ||
var configFilePath = path.normalize(path.join(found, source)); | ||
try { | ||
config = JSON.parse( | ||
stripJSONComments( | ||
fs.readFileSync(configFilePath, 'utf-8').trim())); | ||
} catch (e) { | ||
throw new Error(e + ' ' + configFilePath); | ||
} | ||
if (source == 'package.json') { | ||
config = config.rtlcssConfig; | ||
} | ||
if (config) | ||
return config; | ||
} | ||
} | ||
} | ||
function override(to,from){ | ||
if(to && from){ | ||
for(var p in from){ | ||
if(typeof to[p] === 'object'){ | ||
override(to[p], from[p]); | ||
}else { | ||
to[p] = from[p]; | ||
} | ||
} | ||
} | ||
function override(to, from) { | ||
if (to && from) { | ||
for (var p in from) { | ||
if (typeof to[p] === 'object') { | ||
override(to[p], from[p]); | ||
} else { | ||
to[p] = from[p]; | ||
} | ||
} | ||
} | ||
} | ||
module.exports.load = function(configFilePath, cwd, overrides){ | ||
if(configFilePath){ | ||
return override( | ||
JSON.parse( | ||
stripJSONComments( | ||
fs.readFileSync(configFilePath,'utf-8').trim() | ||
) | ||
), overrides); | ||
} | ||
var directory = cwd || process.cwd(); | ||
var config = loadConfig(directory); | ||
if(!config){ | ||
var evns = [process.env.USERPROFILE, process.env.HOMEPATH, process.env.HOME]; | ||
for(var x=0;x<evns.length;x++){ | ||
if(!evns[x]){ | ||
continue; | ||
} | ||
config = loadConfig(evns[x]); | ||
if(config){ | ||
break; | ||
} | ||
} | ||
} | ||
if(config){ | ||
override(config, overrides); | ||
} | ||
return config; | ||
module.exports.load = function (configFilePath, cwd, overrides) { | ||
if (configFilePath) { | ||
return override( | ||
JSON.parse( | ||
stripJSONComments( | ||
fs.readFileSync(configFilePath, 'utf-8').trim())), overrides); | ||
} | ||
var directory = cwd || process.cwd(); | ||
var config = loadConfig(directory); | ||
if (!config) { | ||
var evns = [process.env.USERPROFILE, process.env.HOMEPATH, process.env.HOME]; | ||
for (var x = 0; x < evns.length; x++) { | ||
if (!evns[x]) { | ||
continue; | ||
} | ||
config = loadConfig(evns[x]); | ||
if (config) { | ||
break; | ||
} | ||
} | ||
} | ||
if (config) { | ||
override(config, overrides); | ||
} | ||
return config; | ||
}; |
@@ -28,3 +28,3 @@ function main(options, rules, declarations, properties) { | ||
config.stringMap.push({ | ||
'name':'left-right', | ||
'name': 'left-right', | ||
'search': ['left', 'Left', 'LEFT'], | ||
@@ -34,7 +34,7 @@ 'replace': ['right', 'Right', 'RIGHT'], | ||
}); | ||
urlFlag = optionOrDefault('swapLtrRtlInUrl', true) | ||
if (!config.stringMap.some(function (map) { return map.name == 'ltr-rtl'; })) | ||
config.stringMap.push({ | ||
'name':'ltr-rtl', | ||
'name': 'ltr-rtl', | ||
'search': ['ltr', 'Ltr', 'LTR'], | ||
@@ -44,7 +44,7 @@ 'replace': ['rtl', 'Rtl', 'RTL'], | ||
}); | ||
urlFlag = optionOrDefault('swapWestEastInUrl', true) | ||
if (!config.stringMap.some(function (map) { return map.name == 'west-east'; })) | ||
config.stringMap.push({ | ||
'name':'west-east', | ||
'name': 'west-east', | ||
'search': ['west', 'West', 'WEST'], | ||
@@ -56,11 +56,11 @@ 'replace': ['east', 'East', 'EAST'], | ||
if (config.minify) | ||
config.preserveComments = config.preserveDirectives = false; | ||
config.preserveComments = config.preserveDirectives = false; | ||
var instructions = require('./instructions.js'); | ||
config.instructions = instructions.configure(config); | ||
if(rules != null && rules.length) | ||
if (rules != null && rules.length) | ||
for (var x = 0; x < rules.length; x++) { | ||
var rule = rules[x]; | ||
if(rule.important) | ||
if (rule.important) | ||
config.instructions.rules.unshift(rule); | ||
@@ -74,3 +74,3 @@ else | ||
var decl = declarations[x]; | ||
if(decl.important) | ||
if (decl.important) | ||
config.instructions.declarations.unshift(decl); | ||
@@ -91,4 +91,4 @@ else | ||
return config; | ||
} | ||
module.exports.configure = main; |
function main(configuration) { | ||
var config = configuration; | ||
var declarations = | ||
var declarations = | ||
[ | ||
@@ -5,0 +5,0 @@ { |
function main(configuration) { | ||
var config = configuration; | ||
var util = require('./util.js').configure(config); | ||
var properties = | ||
var properties = | ||
[ | ||
@@ -34,8 +34,8 @@ { | ||
"saveOthers": function (value) { | ||
var self = this; | ||
return value.replace(this.other, function (m) { self.others.push(m); return "temp" + self.others.length }); | ||
var self = this; | ||
return value.replace(this.other, function (m) { self.others.push(m); return "temp" + self.others.length }); | ||
}, | ||
"restoreOthers": function (value) { | ||
var self = this; | ||
return value.replace(/temp(\d+)/ig, function (m,i) { return self.others[i-1]; }); | ||
var self = this; | ||
return value.replace(/temp(\d+)/ig, function (m, i) { return self.others[i - 1]; }); | ||
}, | ||
@@ -111,3 +111,3 @@ "action": function (prop, value) { | ||
"flip": function (value) { | ||
if(value == "0") | ||
if (value == "0") | ||
return "100%"; | ||
@@ -154,3 +154,3 @@ else if (value.match(this.percent)) | ||
}, | ||
"skewXY": /skew(x|y)?/i, | ||
"skewXY": /skew(x|y)?/i, | ||
"action": function (prop, value) { | ||
@@ -163,3 +163,3 @@ var parts = value.match(this.match); | ||
parts[x] = this.flipRotate3D(parts[x]); | ||
else if (parts[x].match(this.skewXY)) | ||
else if (parts[x].match(this.skewXY)) | ||
parts[x] = util.negateAll(parts[x]); | ||
@@ -259,3 +259,3 @@ else | ||
"flip": function (value) { | ||
return value.replace(this.replace, function (s,m) { return s.replace(m, m.replace(/e/i, "*").replace(/w/i, "e").replace(/\*/i, "w")); }); | ||
return value.replace(this.replace, function (s, m) { return s.replace(m, m.replace(/e/i, "*").replace(/w/i, "e").replace(/\*/i, "w")); }); | ||
}, | ||
@@ -262,0 +262,0 @@ "action": function (prop, value) { |
@@ -1,41 +0,27 @@ | ||
(function() { | ||
"use strict"; | ||
var config,util,postcss; | ||
(function () { | ||
"use strict"; | ||
var config, util, postcss; | ||
var RTLCSS = (function() { | ||
function RTLCSS(options, rules, declarations, properties) { | ||
postcss = require('postcss'); | ||
config = require('./config.js').configure(options, rules, declarations, properties); | ||
util = require('./util.js').configure(config); | ||
} | ||
RTLCSS.prototype.process = function(css, options) { | ||
return postcss(this.postcss).process(css,options); | ||
}; | ||
RTLCSS.prototype.postcss = function (css) { | ||
css.eachRule(function (rule, idx) { | ||
var previousComment = { 'text': '', removeSelf: function () { } }; | ||
if (idx > 0 && rule.parent.rules[idx - 1].type == 'comment') | ||
previousComment = rule.parent.rules[idx - 1]; | ||
var RTLCSS = (function () { | ||
function RTLCSS(options, rules, declarations, properties) { | ||
postcss = require('postcss'); | ||
config = require('./config.js').configure(options, rules, declarations, properties); | ||
util = require('./util.js').configure(config); | ||
} | ||
RTLCSS.prototype.process = function (css, options) { | ||
return postcss(this.postcss).process(css, options); | ||
}; | ||
RTLCSS.prototype.postcss = function (css) { | ||
css.eachRule(function (rule, idx) { | ||
var previousComment = { 'text': '', removeSelf: function () { } }; | ||
if (idx > 0 && rule.parent.rules[idx - 1].type == 'comment') | ||
previousComment = rule.parent.rules[idx - 1]; | ||
//processing instruction at rule level | ||
for (var x = 0; x < config.instructions.rules.length; x++) { | ||
var pi = config.instructions.rules[x]; | ||
if (("/*" + previousComment.text + "*/").match(pi.expr) && pi.action(rule)) { | ||
util.logRuleAction(rule, pi); | ||
if(!config.preserveDirectives) | ||
previousComment.removeSelf(); | ||
return; | ||
} | ||
} | ||
var flipped = 0; | ||
rule.eachDecl(function (decl, index) { | ||
if (decl.type == "comment") | ||
return; | ||
//processing instruction at declaration level | ||
for (var x = 0; x < config.instructions.declarations.length; x++) { | ||
var pi = config.instructions.declarations[x]; | ||
if (decl._value && decl._value.raw && decl._value.raw.match(pi.expr) && pi.action(decl)) { | ||
util.logDeclAction(decl, pi); | ||
//processing instruction at rule level | ||
for (var x = 0; x < config.instructions.rules.length; x++) { | ||
var pi = config.instructions.rules[x]; | ||
if (("/*" + previousComment.text + "*/").match(pi.expr) && pi.action(rule)) { | ||
util.logRuleAction(rule, pi); | ||
if (!config.preserveDirectives) | ||
previousComment.removeSelf(); | ||
return; | ||
@@ -45,110 +31,124 @@ } | ||
//processing instruction at property level | ||
for (var x = 0; x < config.instructions.properties.length; x++) { | ||
var pi = config.instructions.properties[x]; | ||
if (decl.prop.match(pi.expr)) { | ||
var rawValue = config.preserveComments && decl._value && decl._value.raw ? decl._value.raw : decl.value; | ||
var result; | ||
if (config.preserveComments) { | ||
var commentsLessRawValue = util.saveComments(rawValue); | ||
result = pi.action(decl.prop, commentsLessRawValue); | ||
result.value = util.restoreComments(result.value); | ||
var flipped = 0; | ||
rule.eachDecl(function (decl, index) { | ||
if (decl.type == "comment") | ||
return; | ||
//processing instruction at declaration level | ||
for (var x = 0; x < config.instructions.declarations.length; x++) { | ||
var pi = config.instructions.declarations[x]; | ||
if (decl._value && decl._value.raw && decl._value.raw.match(pi.expr) && pi.action(decl)) { | ||
util.logDeclAction(decl, pi); | ||
return; | ||
} | ||
else | ||
result = pi.action(decl.prop, rawValue); | ||
} | ||
if (result.prop != decl.prop || result.value != rawValue) { | ||
flipped++; | ||
util.logPropAction(decl, result, pi); | ||
decl.prop = result.prop; | ||
decl.value = result.value; | ||
//processing instruction at property level | ||
for (var x = 0; x < config.instructions.properties.length; x++) { | ||
var pi = config.instructions.properties[x]; | ||
if (decl.prop.match(pi.expr)) { | ||
var rawValue = config.preserveComments && decl._value && decl._value.raw ? decl._value.raw : decl.value; | ||
var result; | ||
if (config.preserveComments) { | ||
var commentsLessRawValue = util.saveComments(rawValue); | ||
result = pi.action(decl.prop, commentsLessRawValue); | ||
result.value = util.restoreComments(result.value); | ||
} | ||
else | ||
result = pi.action(decl.prop, rawValue); | ||
if (result.prop != decl.prop || result.value != rawValue) { | ||
flipped++; | ||
util.logPropAction(decl, result, pi); | ||
decl.prop = result.prop; | ||
decl.value = result.value; | ||
} | ||
break; | ||
} | ||
break; | ||
} | ||
}); | ||
if (config.autoRename && flipped == 0) { | ||
rule.selector = util.applyStringMap(rule.selector, true, false); | ||
} | ||
return; | ||
}); | ||
if (config.autoRename && flipped == 0) { | ||
rule.selector = util.applyStringMap(rule.selector, true, false); | ||
//loop @ rules | ||
css.eachAtRule(function (atRule) { | ||
atRule.params = util.applyStringMap(atRule.params, false, true); | ||
if (config.minify) { | ||
atRule.before = ''; | ||
atRule.between = ''; | ||
atRule.after = ''; | ||
delete atRule._params; | ||
} | ||
}); | ||
if (config.minify) { | ||
css.eachDecl(function (decl) { | ||
decl.before = ''; | ||
decl.between = ':'; | ||
delete decl._value; | ||
}); | ||
css.eachRule(function (rule) { | ||
rule.before = ''; | ||
rule.between = ''; | ||
rule.after = ''; | ||
delete rule._selector; | ||
}); | ||
css.eachComment(function (comment) { | ||
comment.removeSelf(); | ||
}); | ||
} | ||
return; | ||
}); | ||
//loop @ rules | ||
css.eachAtRule(function (atRule) { | ||
atRule.params = util.applyStringMap(atRule.params, false, true); | ||
if(config.minify){ | ||
atRule.before = ''; | ||
atRule.between = ''; | ||
atRule.after = ''; | ||
delete atRule._params; | ||
} | ||
}); | ||
if (config.minify) { | ||
css.eachDecl(function (decl) { | ||
decl.before = ''; | ||
decl.between = ':'; | ||
delete decl._value; | ||
}); | ||
css.eachRule(function (rule) { | ||
rule.before = ''; | ||
rule.between = ''; | ||
rule.after = ''; | ||
delete rule._selector; | ||
}); | ||
css.eachComment(function (comment) { | ||
comment.removeSelf(); | ||
}); | ||
} | ||
}; | ||
return RTLCSS; | ||
})(); | ||
/** | ||
* Creates a new RTLCSS instance. | ||
* | ||
* @options {Object} An object containing RTLCSS settings. | ||
* @rules {Object} An object containing RTLCSS rule level processing directives. | ||
* @declarations {Object} An object containing RTLCSS declaration level processing directives. | ||
* @properties {Object} An object containing RTLCSS property level processing directives. | ||
* | ||
* @return {Object} new RTLCSS instance. | ||
*/ | ||
var exports = function (options, rules, declarations, properties) { | ||
return new RTLCSS(options, rules, declarations, properties); | ||
}; | ||
return RTLCSS; | ||
})(); | ||
/** | ||
* Creates a new RTLCSS instance. | ||
* | ||
* @options {Object} An object containing RTLCSS settings. | ||
* @rules {Object} An object containing RTLCSS rule level processing directives. | ||
* @declarations {Object} An object containing RTLCSS declaration level processing directives. | ||
* @properties {Object} An object containing RTLCSS property level processing directives. | ||
* | ||
* @return {Object} new RTLCSS instance. | ||
*/ | ||
var exports = function(options, rules, declarations, properties) { | ||
return new RTLCSS(options, rules, declarations, properties); | ||
}; | ||
/** | ||
* Creates a new RTLCSS instance, process the input and return its result. | ||
* | ||
* @css {String} A string containing input CSS. | ||
* @options {Object} An object containing RTLCSS settings. | ||
* @rules {Object} An object containing RTLCSS rule level processing directives. | ||
* @declarations {Object} An object containing RTLCSS declaration level processing directives. | ||
* @properties {Object} An object containing RTLCSS property level processing directives. | ||
* | ||
* @return {String} A string contining the RTLed css. | ||
*/ | ||
exports.process = function(css, options, rules, declarations, properties){ | ||
return new RTLCSS(options, rules, declarations, properties).process(css).css; | ||
} | ||
/** | ||
* Creates a new instance of RTLCSS using the passed configuration object | ||
* | ||
* @config {Object} An object containing RTLCSS options, rules, declarations and properties processing directives. | ||
* | ||
* @return {Object} A new RTLCSS instance. | ||
*/ | ||
exports.configure = function(config){ | ||
config = config || {}; | ||
return new RTLCSS(config.options, config.rules, config.declarations, config.properties); | ||
} | ||
/** | ||
* Creates a new RTLCSS instance, process the input and return its result. | ||
* | ||
* @css {String} A string containing input CSS. | ||
* @options {Object} An object containing RTLCSS settings. | ||
* @rules {Object} An object containing RTLCSS rule level processing directives. | ||
* @declarations {Object} An object containing RTLCSS declaration level processing directives. | ||
* @properties {Object} An object containing RTLCSS property level processing directives. | ||
* | ||
* @return {String} A string contining the RTLed css. | ||
*/ | ||
exports.process = function (css, options, rules, declarations, properties) { | ||
return new RTLCSS(options, rules, declarations, properties).process(css).css; | ||
} | ||
module.exports = exports; | ||
/** | ||
* Creates a new instance of RTLCSS using the passed configuration object | ||
* | ||
* @config {Object} An object containing RTLCSS options, rules, declarations and properties processing directives. | ||
* | ||
* @return {Object} A new RTLCSS instance. | ||
*/ | ||
exports.configure = function (config) { | ||
config = config || {}; | ||
return new RTLCSS(config.options, config.rules, config.declarations, config.properties); | ||
} | ||
module.exports = exports; | ||
}).call(this); |
function main(configuration) { | ||
var config = configuration; | ||
var util = require('./util.js').configure(config); | ||
var rules = | ||
var rules = | ||
[ | ||
@@ -6,0 +6,0 @@ { |
function main(configuration) { | ||
var config = configuration; | ||
chalk = require('chalk'), | ||
success = chalk.green, | ||
info = chalk.cyan, | ||
REPLACEMENT_CHARACTER = '\uFFFD', | ||
REGEX_COMMENT = /\/\*(.|\s)*?\*\//gm, | ||
DEFAULT_STRING_MAP_OPTIONS = { scope: '*', ignoreCase: true }, | ||
compare = function (what, to, ignoreCase) { | ||
if (ignoreCase) | ||
return what.toLowerCase() === to.toLowerCase(); | ||
return what === to; | ||
}, | ||
extend = function (dest, src) { | ||
if (typeof dest === 'undefined' || typeof dest !== 'object') | ||
dest = {}; | ||
for (var prop in src) { | ||
if (!dest.hasOwnProperty(prop)) { | ||
dest[prop] = src[prop]; | ||
var config = configuration, | ||
chalk = require('chalk'), | ||
success = chalk.green, | ||
info = chalk.cyan, | ||
REPLACEMENT_CHARACTER = '\uFFFD', | ||
REGEX_COMMENT = /\/\*(.|\s)*?\*\//gm, | ||
DEFAULT_STRING_MAP_OPTIONS = { scope: '*', ignoreCase: true }, | ||
compare = function (what, to, ignoreCase) { | ||
if (ignoreCase) { | ||
return what.toLowerCase() === to.toLowerCase(); | ||
} | ||
return what === to; | ||
}, | ||
extend = function (dest, src) { | ||
if (typeof dest === 'undefined' || typeof dest !== 'object') { | ||
dest = {}; | ||
} | ||
for (var prop in src) { | ||
if (!dest.hasOwnProperty(prop)) { | ||
dest[prop] = src[prop]; | ||
} | ||
} | ||
return dest; | ||
} | ||
} | ||
return dest; | ||
}; | ||
var util = | ||
; | ||
var util = | ||
{ | ||
@@ -61,9 +63,7 @@ log: function () { | ||
options = options || DEFAULT_STRING_MAP_OPTIONS; | ||
var greedy = options.hasOwnProperty('greedy') ? options.greedy : config.greedy; | ||
if (!greedy) | ||
expr = "\\b(" + expr + ")\\b"; | ||
if (!greedy) { | ||
expr = "\\b(" + expr + ")\\b"; | ||
} | ||
var flags = options.ignoreCase ? "img" : "mg"; | ||
return value.replace(new RegExp(expr, flags), function (m) { return compare(m, a, options.ignoreCase) ? b : a; }); | ||
@@ -80,10 +80,6 @@ }, | ||
for (var x = 0; x < config.stringMap.length; x++) { | ||
var map = config.stringMap[x]; | ||
var options = extend(map.options, DEFAULT_STRING_MAP_OPTIONS); | ||
if (options.scope === '*' || (inSelector && options.scope == 'selector') || (inUrl && options.scope == 'url')) { | ||
this.log(info('Applying string map: ' + (map.name || "<unknown>") + '.')); | ||
if (map.search instanceof Array && map.replace instanceof Array) { | ||
@@ -90,0 +86,0 @@ for (var mapIndex = 0; mapIndex < map.search.length; mapIndex++) { |
{ | ||
"author": "Mohammad Younes", | ||
"name": "rtlcss", | ||
"version": "1.3.1", | ||
"description": "Framework for transforming cascading style sheets (CSS) from left-to-right (LTR) to right-to-left (RTL)", | ||
"version": "1.4.0", | ||
"description": "Framework for transforming cascading style sheets (CSS) from left-to-right (LTR) to right-to-left (RTL)", | ||
"bugs": "https://github.com/MohammadYounes/rtlcss/issues?state=open", | ||
"license": "MIT", | ||
"keywords": ["rtl","css","ltr","rtlcss", "framework","style", "mirror", "flip", "convert", "transform"], | ||
"keywords": [ "rtl", "css", "ltr", "rtlcss", "framework", "style", "mirror", "flip", "convert", "transform" ], | ||
"repository": { | ||
"type": "git", | ||
"url": "https://github.com/MohammadYounes/rtlcss.git" | ||
"url": "https://github.com/MohammadYounes/rtlcss.git" | ||
}, | ||
@@ -17,6 +17,7 @@ "bin": { | ||
"dependencies": { | ||
"postcss":"2.2.5", | ||
"chalk":"0.5.1", | ||
"findup":"0.1.5", | ||
"strip-json-comments":"1.0.1" | ||
"postcss": "2.2.5", | ||
"chalk": "0.5.1", | ||
"findup": "0.1.5", | ||
"strip-json-comments": "1.0.1", | ||
"mkdirp": "0.5.0" | ||
}, | ||
@@ -27,5 +28,5 @@ "devDependencies": { | ||
"scripts": { | ||
"test": "mocha -R spec" | ||
"test": "mocha -R spec" | ||
}, | ||
"main": "./lib/rtlcss" | ||
} |
@@ -365,2 +365,5 @@ [![GitHub version](https://badge.fury.io/gh/MohammadYounes%2Frtlcss.svg)](http://badge.fury.io/gh/MohammadYounes%2Frtlcss) | ||
## Release Notes | ||
* **v1.4.0** [10 Oct. 2014] | ||
* CLI: Support processing a directory. see [CLI documentation](https://github.com/MohammadYounes/rtlcss/blob/master/CLI.md#directory) | ||
* **v1.3.1** [29 Sep. 2014] | ||
@@ -367,0 +370,0 @@ * Update README.md (typos). |
273
test/test.js
@@ -41,15 +41,15 @@ var assert = require("assert"); | ||
}, | ||
{ | ||
'should': 'Should not swap bright:bleft, ultra:urtla, westing:easting', | ||
'expected': '.banner { background: 10px top url(ultra/westing/bright.png) #00D repeat-y fixed; }', | ||
'input': '.banner { background: 10px top url(ultra/westing/bright.png) #00D repeat-y fixed; }', | ||
'reversable': true | ||
}, | ||
{ | ||
'should': 'Should swap bright:bleft, ultra:urtla, westing:easting (greedy)', | ||
'expected': '.banner { background: 10px top url(urtla/easting/bleft.png) #00D repeat-y fixed; }', | ||
'input': '.banner { background: 10px top url(ultra/westing/bright.png) #00D repeat-y fixed; }', | ||
'reversable': true, | ||
'options': { 'greedy': true } | ||
}, | ||
{ | ||
'should': 'Should not swap bright:bleft, ultra:urtla, westing:easting', | ||
'expected': '.banner { background: 10px top url(ultra/westing/bright.png) #00D repeat-y fixed; }', | ||
'input': '.banner { background: 10px top url(ultra/westing/bright.png) #00D repeat-y fixed; }', | ||
'reversable': true | ||
}, | ||
{ | ||
'should': 'Should swap bright:bleft, ultra:urtla, westing:easting (greedy)', | ||
'expected': '.banner { background: 10px top url(urtla/easting/bleft.png) #00D repeat-y fixed; }', | ||
'input': '.banner { background: 10px top url(ultra/westing/bright.png) #00D repeat-y fixed; }', | ||
'reversable': true, | ||
'options': { 'greedy': true } | ||
} | ||
], | ||
@@ -207,56 +207,56 @@ 'Background Image:': [ | ||
}, | ||
{ | ||
'should': 'Should mirror property value: float', | ||
'expected': 'div { float:right; }', | ||
'input': 'div { float:left; }', | ||
'reversable': true | ||
}, | ||
{ | ||
'should': 'Should mirror property value: text-align', | ||
'expected': 'div { text-align:right; }', | ||
'input': 'div { text-align:left; }', | ||
'reversable': true | ||
}, | ||
{ | ||
'should': 'Should mirror property value: cursor nw', | ||
'expected': 'div { cursor:nw-resize; }', | ||
'input': 'div { cursor:ne-resize; }', | ||
'reversable': true | ||
}, | ||
{ | ||
'should': 'Should mirror property value: cursor sw', | ||
'expected': 'div { cursor:sw-resize; }', | ||
'input': 'div { cursor:se-resize; }', | ||
'reversable': true | ||
}, | ||
{ | ||
'should': 'Should mirror property value: cursor nesw', | ||
'expected': 'div { cursor:nesw-resize; }', | ||
'input': 'div { cursor:nwse-resize; }', | ||
'reversable': true | ||
}, | ||
{ | ||
'should': 'Should keep property value as is: cursor ns', | ||
'expected': 'div { cursor:ns-resize; }', | ||
'input': 'div { cursor:ns-resize; }', | ||
'reversable': false | ||
}, | ||
{ | ||
'should': 'Should swap left,ltr,west in url: cursor', | ||
'expected': '.foo { cursor: url(right.cur), url(rtl.cur), url(east.cur), se-resize, auto }', | ||
'input': '.foo { cursor: url(left.cur), url(ltr.cur), url(west.cur), sw-resize, auto }', | ||
'reversable': true | ||
}, | ||
{ | ||
'should': 'Should mirror property value: transition', | ||
'expected': '.foo { transition: right .3s ease .1s, left .3s ease .1s, margin-right .3s ease, margin-left .3s ease, padding-right .3s ease, padding-left .3s ease}', | ||
'input': '.foo { transition: left .3s ease .1s, right .3s ease .1s, margin-left .3s ease, margin-right .3s ease, padding-left .3s ease, padding-right .3s ease}', | ||
'reversable': true | ||
}, | ||
{ | ||
'should': 'Should mirror property value: transition-property', | ||
'expected': '.foo { transition-property: right; }', | ||
'input': '.foo { transition-property: left; }', | ||
'reversable': true | ||
}, | ||
{ | ||
'should': 'Should mirror property value: float', | ||
'expected': 'div { float:right; }', | ||
'input': 'div { float:left; }', | ||
'reversable': true | ||
}, | ||
{ | ||
'should': 'Should mirror property value: text-align', | ||
'expected': 'div { text-align:right; }', | ||
'input': 'div { text-align:left; }', | ||
'reversable': true | ||
}, | ||
{ | ||
'should': 'Should mirror property value: cursor nw', | ||
'expected': 'div { cursor:nw-resize; }', | ||
'input': 'div { cursor:ne-resize; }', | ||
'reversable': true | ||
}, | ||
{ | ||
'should': 'Should mirror property value: cursor sw', | ||
'expected': 'div { cursor:sw-resize; }', | ||
'input': 'div { cursor:se-resize; }', | ||
'reversable': true | ||
}, | ||
{ | ||
'should': 'Should mirror property value: cursor nesw', | ||
'expected': 'div { cursor:nesw-resize; }', | ||
'input': 'div { cursor:nwse-resize; }', | ||
'reversable': true | ||
}, | ||
{ | ||
'should': 'Should keep property value as is: cursor ns', | ||
'expected': 'div { cursor:ns-resize; }', | ||
'input': 'div { cursor:ns-resize; }', | ||
'reversable': false | ||
}, | ||
{ | ||
'should': 'Should swap left,ltr,west in url: cursor', | ||
'expected': '.foo { cursor: url(right.cur), url(rtl.cur), url(east.cur), se-resize, auto }', | ||
'input': '.foo { cursor: url(left.cur), url(ltr.cur), url(west.cur), sw-resize, auto }', | ||
'reversable': true | ||
}, | ||
{ | ||
'should': 'Should mirror property value: transition', | ||
'expected': '.foo { transition: right .3s ease .1s, left .3s ease .1s, margin-right .3s ease, margin-left .3s ease, padding-right .3s ease, padding-left .3s ease}', | ||
'input': '.foo { transition: left .3s ease .1s, right .3s ease .1s, margin-left .3s ease, margin-right .3s ease, padding-left .3s ease, padding-right .3s ease}', | ||
'reversable': true | ||
}, | ||
{ | ||
'should': 'Should mirror property value: transition-property', | ||
'expected': '.foo { transition-property: right; }', | ||
'input': '.foo { transition-property: left; }', | ||
'reversable': true | ||
} | ||
], | ||
@@ -619,66 +619,66 @@ 'Mirrored Values (N Value Syntax):': [ | ||
}, | ||
{ | ||
'should': 'Should swap left with right in @import url (swapLeftRightInUrl:true)', | ||
'expected': 'div{display:none;} @import url("right.css");', | ||
'input': 'div{display:none;} @import url("left.css");', | ||
'reversable': true, | ||
'options': { 'swapLeftRightInUrl': true } | ||
}, | ||
{ | ||
'should': 'Should not swap bright with bleft in @import url (swapLeftRightInUrl:true,greedy:false)', | ||
'expected': 'div{display:none;} @import url("bright.css");', | ||
'input': 'div{display:none;} @import url("bright.css");', | ||
'reversable': true, | ||
'options': { 'swapLeftRightInUrl': true, 'greedy': false } | ||
}, | ||
{ | ||
'should': 'Should swap bright with bleft in @import url (swapLeftRightInUrl:true,greedy:true)', | ||
'expected': 'div{display:none;} @import url("bleft.css");', | ||
'input': 'div{display:none;} @import url("bright.css");', | ||
'reversable': true, | ||
'options': { 'swapLeftRightInUrl': true, 'greedy': true } | ||
}, | ||
{ | ||
'should': 'Should swap ltr with rtl in @import url (swapLtrRtlInUrl:true)', | ||
'expected': 'div{display:none;} @import url("rtl.css");', | ||
'input': 'div{display:none;} @import url("ltr.css");', | ||
'reversable': true, | ||
'options': { 'swapLtrRtlInUrl': true } | ||
}, | ||
{ | ||
'should': 'Should not swap ultra with urtla in @import url (swapLtrRtlInUrl:true,greedy:false)', | ||
'expected': 'div{display:none;} @import url("ultra.css");', | ||
'input': 'div{display:none;} @import url("ultra.css");', | ||
'reversable': true, | ||
'options': { 'swapLtrRtlInUrl': true, 'greedy': false } | ||
}, | ||
{ | ||
'should': 'Should swap ultra with urtla in @import url (swapLtrRtlInUrl:true,greedy:true)', | ||
'expected': 'div{display:none;} @import url("urtla.css");', | ||
'input': 'div{display:none;} @import url("ultra.css");', | ||
'reversable': true, | ||
'options': { 'swapLtrRtlInUrl': true, 'greedy': true } | ||
}, | ||
{ | ||
'should': 'Should swap west with east in @import url (swapWestEastInUrl:true)', | ||
'expected': 'div{display:none;} @import url("east.css");', | ||
'input': 'div{display:none;} @import url("west.css");', | ||
'reversable': true, | ||
'options': { 'swapWestEastInUrl': true } | ||
}, | ||
{ | ||
'should': 'Should not swap western with eastern in @import url (swapWestEastInUrl:true,greedy:false)', | ||
'expected': 'div{display:none;} @import url("western.css");', | ||
'input': 'div{display:none;} @import url("western.css");', | ||
'reversable': true, | ||
'options': { 'swapWestEastInUrl': true, 'greedy': false } | ||
}, | ||
{ | ||
'should': 'Should swap western with eastern in @import url (swapWestEastInUrl:true,greedy:true)', | ||
'expected': 'div{display:none;} @import url("eastern.css");', | ||
'input': 'div{display:none;} @import url("western.css");', | ||
'reversable': true, | ||
'options': { 'swapWestEastInUrl': true, 'greedy': true } | ||
}, | ||
{ | ||
'should': 'Should swap left with right in @import url (swapLeftRightInUrl:true)', | ||
'expected': 'div{display:none;} @import url("right.css");', | ||
'input': 'div{display:none;} @import url("left.css");', | ||
'reversable': true, | ||
'options': { 'swapLeftRightInUrl': true } | ||
}, | ||
{ | ||
'should': 'Should not swap bright with bleft in @import url (swapLeftRightInUrl:true,greedy:false)', | ||
'expected': 'div{display:none;} @import url("bright.css");', | ||
'input': 'div{display:none;} @import url("bright.css");', | ||
'reversable': true, | ||
'options': { 'swapLeftRightInUrl': true, 'greedy': false } | ||
}, | ||
{ | ||
'should': 'Should swap bright with bleft in @import url (swapLeftRightInUrl:true,greedy:true)', | ||
'expected': 'div{display:none;} @import url("bleft.css");', | ||
'input': 'div{display:none;} @import url("bright.css");', | ||
'reversable': true, | ||
'options': { 'swapLeftRightInUrl': true, 'greedy': true } | ||
}, | ||
{ | ||
'should': 'Should swap ltr with rtl in @import url (swapLtrRtlInUrl:true)', | ||
'expected': 'div{display:none;} @import url("rtl.css");', | ||
'input': 'div{display:none;} @import url("ltr.css");', | ||
'reversable': true, | ||
'options': { 'swapLtrRtlInUrl': true } | ||
}, | ||
{ | ||
'should': 'Should not swap ultra with urtla in @import url (swapLtrRtlInUrl:true,greedy:false)', | ||
'expected': 'div{display:none;} @import url("ultra.css");', | ||
'input': 'div{display:none;} @import url("ultra.css");', | ||
'reversable': true, | ||
'options': { 'swapLtrRtlInUrl': true, 'greedy': false } | ||
}, | ||
{ | ||
'should': 'Should swap ultra with urtla in @import url (swapLtrRtlInUrl:true,greedy:true)', | ||
'expected': 'div{display:none;} @import url("urtla.css");', | ||
'input': 'div{display:none;} @import url("ultra.css");', | ||
'reversable': true, | ||
'options': { 'swapLtrRtlInUrl': true, 'greedy': true } | ||
}, | ||
{ | ||
'should': 'Should swap west with east in @import url (swapWestEastInUrl:true)', | ||
'expected': 'div{display:none;} @import url("east.css");', | ||
'input': 'div{display:none;} @import url("west.css");', | ||
'reversable': true, | ||
'options': { 'swapWestEastInUrl': true } | ||
}, | ||
{ | ||
'should': 'Should not swap western with eastern in @import url (swapWestEastInUrl:true,greedy:false)', | ||
'expected': 'div{display:none;} @import url("western.css");', | ||
'input': 'div{display:none;} @import url("western.css");', | ||
'reversable': true, | ||
'options': { 'swapWestEastInUrl': true, 'greedy': false } | ||
}, | ||
{ | ||
'should': 'Should swap western with eastern in @import url (swapWestEastInUrl:true,greedy:true)', | ||
'expected': 'div{display:none;} @import url("eastern.css");', | ||
'input': 'div{display:none;} @import url("western.css");', | ||
'reversable': true, | ||
'options': { 'swapWestEastInUrl': true, 'greedy': true } | ||
}, | ||
{ | ||
'should': 'Should minify (minify:true)', | ||
@@ -935,3 +935,3 @@ 'expected': 'div{font-family:"Droid Arabic Kufi";padding:10px 5px 5px 10px;color:red;}.div2{display:none;}', | ||
'input': 'div.left, div.Left, div.LEFT, div.respectLeft { width:10px;}', | ||
'reversable':true | ||
'reversable': true | ||
}, | ||
@@ -944,3 +944,3 @@ { | ||
'options': { | ||
'greedy':true | ||
'greedy': true | ||
} | ||
@@ -982,3 +982,3 @@ }, | ||
'input': 'div.prev, div.Left { width:10px;}', | ||
'reversable':true, | ||
'reversable': true, | ||
'options': { 'stringMap': [{ "search": "prev", "replace": "next", 'options': { scope: 'selector' } }] } | ||
@@ -1004,3 +1004,3 @@ }, | ||
'input': 'div.previous{ width:10px;}', | ||
'reversable':true, | ||
'reversable': true, | ||
'options': { 'stringMap': [{ "name": "prev-next", "search": "prev", "replace": "next", options: { greedy: true } }] } | ||
@@ -1022,3 +1022,3 @@ } | ||
})(item); | ||
if (item.reversable) | ||
if (item.reversable) { | ||
(function (test) { | ||
@@ -1029,5 +1029,6 @@ it(test.should + " <REVERESE>", function () { | ||
})(item); | ||
} | ||
}; | ||
}); | ||
} | ||
})(); | ||
})(); |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
102624
2040
438
5
+ Addedmkdirp@0.5.0
+ Addedminimist@0.0.8(transitive)
+ Addedmkdirp@0.5.0(transitive)