Socket
Socket
Sign inDemoInstall

rtlcss

Package Overview
Dependencies
Maintainers
1
Versions
67
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

rtlcss - npm Package Compare versions

Comparing version 0.8.0 to 0.9.0

.rtlcssrc

109

bin/rtlcss.js

@@ -1,12 +0,18 @@

#!/usr/bin/env node
#!/usr/bin/env node
var path = require('path'),
fs = require('fs'),
sys = require('util'),
rtlcss = require('../lib/rtlcss')
chalk = require('chalk'),
postcss = require('postcss');
rtlcss = require('../lib/rtlcss'),
configLoader = require('../lib/config-loader'),
chalk = require('chalk');
var shouldBreak = false, inputFile,outputFile,config = {};
var arg, args = process.argv.slice(2);
var shouldBreak = false, inputFile,outputFile,config;
var currentErrorcode, arg, args = process.argv.slice(2);
process.on('exit', function() { process.reallyExit(currentErrorcode) });
function printWarning (){
console.log(chalk.yellow.apply(this,printWarning.arguments));
}
function printInfo (){

@@ -21,12 +27,12 @@ console.log(chalk.green.apply(this,printInfo.arguments));

function printHelp(){
console.log("Usage: rtlcss [option option=parameter ...] [source] [destination]");
console.log("");
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 <config.json>.",
"- ,--stdin" ,"RTLCSS will read from stdin stream."
'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.'
];

@@ -37,7 +43,7 @@

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");
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');
}

@@ -54,3 +60,3 @@

case '--version':
printInfo("rtlcss version: " + require('../package.json').version);
printInfo('rtlcss version: ' + require('../package.json').version);
shouldBreak = true;

@@ -63,8 +69,9 @@ break;

{
config = JSON.parse(fs.readFileSync(path.resolve(arg),'utf-8'));
config = configLoader.load(path.resolve(arg));
}
catch(e)
{
printError('invalid config file:', e);
printError('rtlcss: invalid config file. ', e);
shouldBreak = true;
currentErrorcode = 1;
}

@@ -78,3 +85,3 @@ break;

if(arg[0] == '-'){
printError("unknown option: " + arg);
printError('rtlcss: unknown option. ' + arg);
shouldBreak = true;

@@ -95,28 +102,49 @@ }else{

if (!inputFile) {
printError("RTLCSS: no input file");
console.log("");
printError('rtlcss: no input file');
console.log('');
printHelp();
return;
}
if(!config && inputFile !== '-'){
try{
config = configLoader.load(null, path.dirname(inputFile));
}catch(e){
printError('rtlcss: invalid config file. ', e);
currentErrorcode = 1;
return;
}
}
if(!outputFile && inputFile != "-")
outputFile = path.extname(inputFile) ? inputFile.replace(/\.[^.]*$/, function(ext){ return ".rtl" + ext;}) : inputFile + ".rtl";
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);
printError('rtlcss: ' + e.message);
return;
}
var processor = rtlcss(config.options,
config.rules,
config.declarations,
config.properties).postcss;
var css = postcss()
.use(processor)
.process(data,{ map: config.map, from:inputFile, to:outputFile});
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);
}
if (outputFile) {
fs.writeFileSync(outputFile, css, 'utf8');
fs.writeFileSync(outputFile, result.css, 'utf8');
if(opt.map == true){
fs.writeFileSync(outputFile + '.map', result.map, 'utf8');
}
} else {
sys.print(css);
sys.print(result.css);
}

@@ -135,3 +163,6 @@ };

});
process.on('SIGINT', function(){
processCSSFile(false, buffer);
process.exit();
});
process.stdin.on('end', function() {

@@ -138,0 +169,0 @@ processCSSFile(false, buffer);

@@ -1,2 +0,2 @@

RTLCSS CLI
RTLCSS CLI
======

@@ -42,3 +42,8 @@

### Config
Set the configuration settings `config.json` path
Configuration can be set using one of the following methods:
* Specify the configuration file manually via the --config flag.
* Put your config into your projects package.json file under the `rtlcssConfig` property.
* Use a special file `.rtlcssrc` or `.rtlcssrc.json`.
```

@@ -49,3 +54,3 @@ $ rtlcss -c

Default `config.json`
Default `.rtlcssrc`
```JAVASCRIPT

@@ -52,0 +57,0 @@ {

@@ -99,12 +99,46 @@ (function() {

var rtlcss = function(options, rules, declarations, properties) {
/**
* 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);
};
rtlcss.process = function(css, 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;
}
module.exports = rtlcss;
/**
* 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);
{
"author": "Mohammad Younes",
"name": "rtlcss",
"version": "0.8.0",
"version": "0.9.0",
"description": "Framework for transforming cascading style sheets (CSS) from left-to-right (LTR) to right-to-left (RTL)",

@@ -18,3 +18,5 @@ "bugs": "https://github.com/MohammadYounes/rtlcss/issues?state=open",

"postcss":"0.3.4",
"chalk":"0.4.0"
"chalk":"0.4.0",
"findup":"0.1.5",
"strip-json-comments":"1.0.1"
},

@@ -21,0 +23,0 @@ "devDependencies": {

@@ -110,3 +110,16 @@ [![GitHub version](https://badge.fury.io/gh/MohammadYounes%2Frtlcss.svg)](http://badge.fury.io/gh/MohammadYounes%2Frtlcss)

```javascript
rtlcss.process(css [, options , rules, declarations, properties]);
// directly processes css and return a string containing the processed css
output = rtlcss.process(css [, options , rules, declarations, properties]);
output // processed CSS
// create a new RTLCSS instance, then process css with postcss options (such as source map)
result = rtlcss([options , rules, declarations, properties]).process(css, postcssOptions);
result.css // Processed CSS
result.map // Source map
// you can also group all configuration settings into a single object
result = rtlcss.configure(config).process(css, postcssOptions);
result.css // Processed CSS
result.map // Source map
```

@@ -118,3 +131,3 @@ > Built on top of [PostCSS], an awesome framework, providing you with the power of manipulating CSS via a JS API.

var processed = postcss()
.use(rtlcss(/* options , rules, declarations, properties*/).postcss)
.use(rtlcss([options , rules, declarations, properties]).postcss)
.use(autoprefixer().postcss)

@@ -138,4 +151,4 @@ .process(css);

|**`minify`** | `false` | Minifies output CSS, when set to `true` both `preserveDirectives` and `preserveComments` will be set to `false` .
|**`postcssOptions`** | `{}` | POSTCSS options object.
### rules (array)

@@ -227,2 +240,9 @@ Array of RTLCSS rule Processing Instructions (PI), these are applied on the CSS rule level:

## Release Notes
* **v0.9.0** [10 Aug. 2014]
* New configuration loader.
* CLI configuration can be set using one of the following methods:
* Specify the configuration file manually via the --config flag.
* Put your config into your projects package.json file under the `rtlcssConfig` property
* Use a special file `.rtlcssrc` or `.rtlcssrc.json`
* **v0.8.0** [8 Aug. 2014]

@@ -229,0 +249,0 @@ * Fix source map generation.

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc