Comparing version 3.0.0 to 3.1.0
#!/usr/bin/env node | ||
'use strict' | ||
const path = require('path') | ||
@@ -10,2 +11,3 @@ const fs = require('fs') | ||
const configLoader = require('../lib/config-loader') | ||
const { version, bugs } = require('../package.json') | ||
@@ -18,12 +20,12 @@ let input, output, directory, ext, config, currentErrorcode, arg | ||
function printWarning () { | ||
console.warn(chalk.yellow.apply(this, printWarning.arguments)) | ||
function printWarning (...args) { | ||
console.warn(chalk.yellow(...args)) | ||
} | ||
function printInfo () { | ||
console.info(chalk.green.apply(this, printInfo.arguments)) | ||
function printInfo (...args) { | ||
console.info(chalk.green(...args)) | ||
} | ||
function printError () { | ||
console.error(chalk.red.apply(this, printError.arguments)) | ||
function printError (...args) { | ||
console.error(chalk.red(...args)) | ||
} | ||
@@ -34,3 +36,3 @@ | ||
console.log('') | ||
/*eslint-disable*/ | ||
/* eslint-disable no-multi-spaces, comma-spacing */ | ||
const options = [ | ||
@@ -43,7 +45,7 @@ 'Option ' , 'Description ', | ||
'- ,--stdin' , 'Read from stdin stream.', | ||
'-d,--dirctory' , 'Process all *.css files from input directory (recursive).', | ||
'-d,--directory', 'Process all *.css files from input directory (recursive).', | ||
'-e,--ext' , 'Used with -d option to set the output files extension.\n\t\t Default: ".rtl.css".', | ||
'-s,--silent' , 'Silent mode, no warnings or errors are printed.' | ||
] | ||
/* eslint-enable */ | ||
/* eslint-enable no-multi-spaces, comma-spacing */ | ||
for (let x = 0; x < options.length; x++) { | ||
@@ -55,4 +57,4 @@ console.log(options[x++], '\t', options[x]) | ||
console.log('') | ||
printInfo('RTLCSS version: ' + require('../package.json').version) | ||
printInfo('Report issues to: https://github.com/MohammadYounes/rtlcss/issues') | ||
printInfo('RTLCSS version: ' + version) | ||
printInfo('Report issues to: ' + bugs.url) | ||
} | ||
@@ -68,3 +70,3 @@ while ((arg = args.shift())) { | ||
case '--version': | ||
printInfo('rtlcss version: ' + require('../package.json').version) | ||
printInfo('rtlcss version: ' + version) | ||
shouldBreak = true | ||
@@ -103,8 +105,6 @@ break | ||
shouldBreak = true | ||
} else { | ||
if (!input) { | ||
input = path.resolve(arg) | ||
} else if (!output) { | ||
output = path.resolve(arg) | ||
} | ||
} else if (!input) { | ||
input = path.resolve(arg) | ||
} else if (!output) { | ||
output = path.resolve(arg) | ||
} | ||
@@ -111,0 +111,0 @@ break |
@@ -0,1 +1,7 @@ | ||
# 3.1.0 - 30 Jan. 2021 | ||
* Use `strict` mode across all files. **Thanks @XhmikosR** | ||
* Allow value directives to be placed any where inside the declaration value. | ||
* Handle value directives placed after `!important`. | ||
* Fix reading config file sources ([#209](https://github.com/MohammadYounes/rtlcss/issues/209)). | ||
# 3.0.0 - 10 Dec. 2020 | ||
@@ -2,0 +8,0 @@ * Upgrade to [POSTCSS] 8. |
@@ -1,2 +0,1 @@ | ||
/* global process */ | ||
'use strict' | ||
@@ -39,8 +38,8 @@ const fs = require('fs') | ||
function loadConfig (dir) { | ||
function loadConfig (cwd) { | ||
for (let x = 0; x < configSources.length; x++) { | ||
let found | ||
let foundPath | ||
const source = configSources[x] | ||
try { | ||
found = findup.sync(dir, source) | ||
foundPath = findup.sync(source, { cwd }) | ||
} catch (e) { | ||
@@ -50,4 +49,4 @@ continue | ||
if (found) { | ||
const configFilePath = path.normalize(path.join(found, source)) | ||
if (foundPath) { | ||
const configFilePath = path.normalize(foundPath) | ||
try { | ||
@@ -75,6 +74,8 @@ config = JSON.parse( | ||
for (const p in from) { | ||
if (typeof to[p] === 'object') { | ||
override(to[p], from[p]) | ||
} else { | ||
to[p] = from[p] | ||
if (Object.prototype.hasOwnProperty.call(from, p)) { | ||
if (Object.prototype.hasOwnProperty.call(to, p) && (typeof to[p] === 'object')) { | ||
override(to[p], from[p]) | ||
} else { | ||
to[p] = from[p] | ||
} | ||
} | ||
@@ -81,0 +82,0 @@ } |
@@ -0,1 +1,2 @@ | ||
'use strict' | ||
module.exports = function (comment) { | ||
@@ -2,0 +3,0 @@ let pos = 0 |
@@ -117,3 +117,3 @@ 'use strict' | ||
} catch (e) { | ||
throw node.error('Invlaid config object', { details: e }) | ||
throw node.error('Invalid config object', { details: e }) | ||
} | ||
@@ -145,6 +145,12 @@ context.config = config.configure(configuration.options, configuration.plugins) | ||
let prefix = '' | ||
decl.raws.value.raw.replace(expr, function (m, v) { | ||
const hasRawValue = decl.raws.value && decl.raws.value.raw | ||
const raw = `${decl.raws.between.substr(1).trim()}${hasRawValue ? decl.raws.value.raw : decl.value}${decl.important ? decl.raws.important.substr(9).trim() : ''}` | ||
raw.replace(expr, function (m, v) { | ||
prefix += v | ||
}) | ||
decl.value = decl.raws.value.raw = prefix + decl.raws.value.raw | ||
if (hasRawValue) { | ||
decl.value = decl.raws.value.raw = prefix + decl.raws.value.raw | ||
} else { | ||
decl.value = prefix + decl.value | ||
} | ||
return true | ||
@@ -156,5 +162,13 @@ } | ||
action: function (decl, expr, context) { | ||
decl.value = decl.raws.value.raw = decl.raws.value.raw.replace(expr, function (match, value) { | ||
return match + value | ||
let suffix = '' | ||
const hasRawValue = decl.raws.value && decl.raws.value.raw | ||
const raw = `${decl.raws.between.substr(1).trim()}${hasRawValue ? decl.raws.value.raw : decl.value}${decl.important ? decl.raws.important.substr(9).trim() : ''}` | ||
raw.replace(expr, function (m, v) { | ||
suffix = v + suffix | ||
}) | ||
if (hasRawValue) { | ||
decl.value = decl.raws.value.raw = decl.raws.value.raw + suffix | ||
} else { | ||
decl.value = decl.value + suffix | ||
} | ||
return true | ||
@@ -166,5 +180,12 @@ } | ||
action: function (decl, expr, context) { | ||
decl.value = decl.raws.value.raw = decl.raws.value.raw.replace(expr, function (match, value) { | ||
return value + match | ||
const hasRawValue = decl.raws.value && decl.raws.value.raw | ||
const raw = `${decl.raws.between.substr(1).trim()}${hasRawValue ? decl.raws.value.raw : decl.value}${decl.important ? decl.raws.important.substr(9).trim() : ''}` | ||
const result = raw.replace(expr, function (match, value) { | ||
return hasRawValue ? value + match : value | ||
}) | ||
if (hasRawValue) { | ||
decl.value = decl.raws.value.raw = result | ||
} else { | ||
decl.value = result | ||
} | ||
return true | ||
@@ -176,4 +197,10 @@ } | ||
action: function (decl, expr, context) { | ||
decl.raws.value.raw.replace(expr, function (match, value) { | ||
decl.value = decl.raws.value.raw = value + match | ||
const hasRawValue = decl.raws.value && decl.raws.value.raw | ||
const raw = `${decl.raws.between.substr(1).trim()}${hasRawValue ? decl.raws.value.raw : ''}${decl.important ? decl.raws.important.substr(9).trim() : ''}` | ||
raw.replace(expr, function (match, value) { | ||
if (hasRawValue) { | ||
decl.value = decl.raws.value.raw = value + match | ||
} else { | ||
decl.value = value | ||
} | ||
}) | ||
@@ -180,0 +207,0 @@ return true |
@@ -5,3 +5,3 @@ /* | ||
* Copyright 2017 Mohammad Younes. | ||
* Licensed under MIT <http://opensource.org/licenses/mit-license.php> | ||
* Licensed under MIT <https://opensource.org/licenses/mit-license.php> | ||
* */ | ||
@@ -123,14 +123,19 @@ 'use strict' | ||
return context.util.each(plugin.directives.value, function (directive) { | ||
if (node.raws.value && node.raws.value.raw) { | ||
const expr = context.util.regexDirective(directive.name) | ||
if (expr.test(node.raws.value.raw)) { | ||
expr.lastIndex = 0 | ||
if (directive.action(node, expr, context)) { | ||
if (context.config.clean) { | ||
const hasRawValue = node.raws.value && node.raws.value.raw | ||
const expr = context.util.regexDirective(directive.name) | ||
if (expr.test(`${node.raws.between}${hasRawValue ? node.raws.value.raw : ''}${node.important ? node.raws.important : ''}`)) { | ||
expr.lastIndex = 0 | ||
if (directive.action(node, expr, context)) { | ||
if (context.config.clean) { | ||
node.raws.between = context.util.trimDirective(node.raws.between) | ||
if (node.important) { | ||
node.raws.important = context.util.trimDirective(node.raws.important) | ||
} | ||
if (hasRawValue) { | ||
node.value = node.raws.value.raw = context.util.trimDirective(node.raws.value.raw) | ||
} | ||
flipped++ | ||
// break | ||
return false | ||
} | ||
flipped++ | ||
// break | ||
return false | ||
} | ||
@@ -137,0 +142,0 @@ } |
@@ -18,3 +18,3 @@ 'use strict' | ||
const REGEX_COMMENT = /\/\*[^]*?\*\//igm // none-greedy | ||
const REGEX_COMMENT = /\/\*[^]*?\*\//igm // non-greedy | ||
const REGEX_DIRECTIVE = /\/\*\s*(?:!)?\s*rtl:[^]*?\*\//img | ||
@@ -96,3 +96,3 @@ const REGEX_ESCAPE = /[.*+?^${}()|[\]\\]/g | ||
state.value = state.value.replace(REGEX_NEGATE_ONE, function (num) { | ||
return REGEX_TOKEN_REPLACEMENT.test(num) ? num.replace(REGEX_TOKEN_REPLACEMENT, function (m) { return '(-1*' + m + ')' }) : parseFloat(num, 10) * -1 | ||
return REGEX_TOKEN_REPLACEMENT.test(num) ? num.replace(REGEX_TOKEN_REPLACEMENT, function (m) { return '(-1*' + m + ')' }) : parseFloat(num) * -1 | ||
}) | ||
@@ -104,3 +104,3 @@ return this.restoreTokens(state) | ||
state.value = state.value.replace(REGEX_NEGATE_ALL, function (num) { | ||
return REGEX_TOKEN_REPLACEMENT.test(num) ? num.replace(REGEX_TOKEN_REPLACEMENT, function (m) { return '(-1*' + m + ')' }) : parseFloat(num, 10) * -1 | ||
return REGEX_TOKEN_REPLACEMENT.test(num) ? num.replace(REGEX_TOKEN_REPLACEMENT, function (m) { return '(-1*' + m + ')' }) : parseFloat(num) * -1 | ||
}) | ||
@@ -112,3 +112,3 @@ return this.restoreTokens(state) | ||
state.value = state.value.replace(REGEX_COMPLEMENT, function (num) { | ||
return REGEX_TOKEN_REPLACEMENT.test(num) ? num.replace(REGEX_TOKEN_REPLACEMENT, function (m) { return '(100% - ' + m + ')' }) : 100 - parseFloat(num, 10) | ||
return REGEX_TOKEN_REPLACEMENT.test(num) ? num.replace(REGEX_TOKEN_REPLACEMENT, function (m) { return '(100% - ' + m + ')' }) : 100 - parseFloat(num) | ||
}) | ||
@@ -130,5 +130,5 @@ return this.restoreTokens(state) | ||
return c | ||
} else { | ||
state.store.push(c); return state.replacement | ||
} | ||
state.store.push(c) | ||
return state.replacement | ||
}) | ||
@@ -189,11 +189,10 @@ return state | ||
return state.value | ||
} else { | ||
return state.value.replace(new RegExp('(\\w*?)' + state.token + CHAR_TOKEN_END, 'i'), function (match, name) { | ||
const value = state.store.shift() | ||
if (typeof callback === 'function') { | ||
return name + callback(value, name) | ||
} | ||
return name + value | ||
}) | ||
} | ||
return state.value.replace(new RegExp('(\\w*?)' + state.token + CHAR_TOKEN_END, 'i'), function (match, name) { | ||
const value = state.store.shift() | ||
if (typeof callback === 'function') { | ||
return name + callback(value, name) | ||
} | ||
return name + value | ||
}) | ||
}, | ||
@@ -249,3 +248,3 @@ guardHexColors: function (value) { | ||
while (next) { | ||
if (next && next.type === node.type) { | ||
if (next.type === node.type) { | ||
isLast = false | ||
@@ -252,0 +251,0 @@ break |
{ | ||
"author": "Mohammad Younes", | ||
"name": "rtlcss", | ||
"version": "3.0.0", | ||
"version": "3.1.0", | ||
"description": "Framework for transforming cascading style sheets (CSS) from left-to-right (LTR) to right-to-left (RTL)", | ||
"homepage": "http://rtlcss.com/", | ||
"bugs": "https://github.com/MohammadYounes/rtlcss/issues?state=open", | ||
"homepage": "https://rtlcss.com/", | ||
"bugs": { | ||
"url": "https://github.com/MohammadYounes/rtlcss/issues" | ||
}, | ||
"license": "MIT", | ||
@@ -23,3 +25,3 @@ "keywords": [ | ||
"type": "git", | ||
"url": "https://github.com/MohammadYounes/rtlcss.git" | ||
"url": "git+https://github.com/MohammadYounes/rtlcss.git" | ||
}, | ||
@@ -44,6 +46,13 @@ "bin": { | ||
"scripts": { | ||
"lint": "standard && node ./lib/rtlcss.js", | ||
"test": "npm run lint && mocha -R spec" | ||
"main": "node ./lib/rtlcss.js", | ||
"lint": "standard", | ||
"lint:fix": "npm run lint -- --fix", | ||
"mocha": "mocha -R spec", | ||
"test": "npm run lint && npm run main && npm run mocha" | ||
}, | ||
"main": "./lib/rtlcss.js" | ||
} | ||
"main": "./lib/rtlcss.js", | ||
"files": [ | ||
"bin/*.js", | ||
"lib/*.js" | ||
] | ||
} |
# RTLCSS | ||
[![Join the chat at https://gitter.im/MohammadYounes/rtlcss](https://badges.gitter.im/MohammadYounes/rtlcss.svg)](https://gitter.im/MohammadYounes/rtlcss?utm_source=badge&utm_medium=badge&utm_campaign=pr-badge&utm_content=badge) | ||
[![Join the chat at https://gitter.im/MohammadYounes/rtlcss](https://img.shields.io/gitter/room/MohammadYounes/rtlcss?color=%2340aa8b)](https://gitter.im/MohammadYounes/rtlcss) | ||
<img style="margin:15px" title="RTL CSS" src="https://cloud.githubusercontent.com/assets/4712046/5889219/190f366a-a425-11e4-8ef5-8b5f60a9e903.png" align="right"/> | ||
<img style="margin:15px" title="RTLCSS" src="https://github.com/MohammadYounes/rtlcss/blob/master/.github/logo.png" align="right"> | ||
[![GitHub version](https://badge.fury.io/gh/MohammadYounes%2Frtlcss.svg)](http://badge.fury.io/gh/MohammadYounes%2Frtlcss) | ||
[![NPM version](https://badge.fury.io/js/rtlcss.svg)](http://badge.fury.io/js/rtlcss) | ||
[![Build Status](https://travis-ci.org/MohammadYounes/rtlcss.svg?branch=master)](https://travis-ci.org/MohammadYounes/rtlcss) | ||
[![DEPENDENCIES](https://david-dm.org/MohammadYounes/rtlcss.svg)](https://david-dm.org/MohammadYounes/rtlcss) | ||
[![GitHub version](https://img.shields.io/github/v/tag/MohammadYounes/rtlcss)](https://github.com/MohammadYounes/rtlcss/releases) | ||
[![npm version](https://img.shields.io/npm/v/rtlcss)](https://www.npmjs.com/package/rtlcss) | ||
[![Build Status](https://github.com/MohammadYounes/rtlcss/workflows/CI/badge.svg?branch=master)](https://github.com/MohammadYounes/rtlcss/actions?query=workflow%3ACI+branch%3Amaster) | ||
[![Dependencies](https://img.shields.io/david/MohammadYounes/rtlcss)](https://david-dm.org/MohammadYounes/rtlcss) | ||
[![js-standard-style](https://img.shields.io/badge/code%20style-standard-blue.svg)](http://standardjs.com/) | ||
[![editor](https://img.shields.io/badge/editor-vscode-blue.svg)](https://code.visualstudio.com/) | ||
[![Twitter](https://img.shields.io/badge/follow-%40rtlcss-blue.svg)](https://twitter.com/rtlcss) | ||
[![js-standard-style](https://img.shields.io/badge/code%20style-standard-blue)](https://standardjs.com/) | ||
[![editor](https://img.shields.io/badge/editor-vscode-blue)](https://code.visualstudio.com/) | ||
[![Twitter](https://img.shields.io/badge/follow-%40rtlcss-blue)](https://twitter.com/rtlcss) | ||
RTLCSS is a framework for converting Left-To-Right (LTR) Cascading Style Sheets(CSS) to Right-To-Left (RTL). | ||
RTLCSS is a framework for converting Left-To-Right (LTR) Cascading Style Sheets(CSS) to Right-To-Left (RTL). | ||
## Documentation | ||
Visit http://rtlcss.com/learn | ||
Visit <https://rtlcss.com/learn/> | ||
## Playground | ||
Visit http://rtlcss.com/playground | ||
Visit <https://rtlcss.com/playground/> | ||
@@ -26,0 +26,0 @@ ## Bugs and Issues |
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
Shell access
Supply chain riskThis module accesses the system shell. Accessing the system shell increases the risk of executing arbitrary code.
Found 1 instance in 1 package
No bug tracker
MaintenancePackage does not have a linked bug tracker in package.json.
Found 1 instance in 1 package
0
5
1
65562
12
1506